+
+
\ No newline at end of file
diff --git a/examples/search/search.iml b/.idea/splunk-sdk-java.iml
similarity index 53%
rename from examples/search/search.iml
rename to .idea/splunk-sdk-java.iml
index be81447e..d6ebd480 100644
--- a/examples/search/search.iml
+++ b/.idea/splunk-sdk-java.iml
@@ -2,13 +2,8 @@
-
-
-
+
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index def6a6a1..9d32e507 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,7 @@
+
diff --git a/examples/info/info.iml b/ApplicationTestWithoutSetup/ApplicationTestWithoutSetup.iml
similarity index 65%
rename from examples/info/info.iml
rename to ApplicationTestWithoutSetup/ApplicationTestWithoutSetup.iml
index be81447e..d5c07432 100644
--- a/examples/info/info.iml
+++ b/ApplicationTestWithoutSetup/ApplicationTestWithoutSetup.iml
@@ -3,12 +3,10 @@
-
+
-
-
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..8aad9ae9
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,678 @@
+# Splunk Enterprise SDK for Java Changelog
+
+## Version 1.9.5
+
+### New Features and APIs
+* Added static method _addClusterMasterURIsToHosts_ in HttpService class to update list of Valid Hosts with Cluster Master Hosts (GitHub PR [#215](https://github.com/splunk/splunk-sdk-java/pull/215))
+* Added instance method _getClusterMasters_ in Service class to get list of cluster master hosts
+
+## Version 1.9.4
+
+### Minor Changes
+* Added check for localhost IPv6 address, for IPv6 compatible apps (GitHub PR [#210](https://github.com/splunk/splunk-sdk-java/pull/210))
+* Updating SSL_SOCKET_FACTORY instance on changing _validateCertificates_ flag. (GitHub PR [#206](https://github.com/splunk/splunk-sdk-java/pull/210))
+
+## Version 1.9.3
+
+### Minor Changes
+* Re-fetch logic for instancetype and version fields if not set within Service instance to avoid NPE (GitHub PR [#202](https://github.com/splunk/splunk-sdk-java/pull/202))
+* Check for local IP as alternative to _localhost_ within HostnameVerifier, addressing issue with certain local workflows
+
+## Version 1.9.2
+
+### New Features and APIs
+* Added feature that allows to update ACL properties of an entity (GitHub PR [#196](https://github.com/splunk/splunk-sdk-java/pull/196))
+
+### Minor Changes
+* Added null check for child to handle error when no value is passed for a parameter in modular-inputs (Ref issue [#198](https://github.com/splunk/splunk-sdk-java/issues/198) & GitHub PR [#199](https://github.com/splunk/splunk-sdk-java/pull/199))
+
+## Version 1.9.1
+
+### New Features and APIs
+* SDK Support for third-party (Load Balancer) "sticky sessions"(cookie persistence) (Github PR [#192](https://github.com/splunk/splunk-sdk-java/pull/192))
+* Added Args option for Saved Search history method (GitHub Issue [#126](https://github.com/splunk/splunk-sdk-java/issues/126) & PR [#188](https://github.com/splunk/splunk-sdk-java/pull/188) )
+
+### Minor Changes
+* Special handling related to the semantic versioning of specific Search APIs functional in Splunk Enterprise 9.0.2 and (Splunk Cloud 9.0.2209). These SDK changes will enable seamless transition between the APIs based on the version of the Splunk Enterprise/Cloud (Github PR [#193](https://github.com/splunk/splunk-sdk-java/pull/193))
+* Updated checks to fetch Storage Passwords with wildcards in namespace. (GitHub PR [#187](https://github.com/splunk/splunk-sdk-java/pull/187))
+
+## Version 1.9.0
+
+### New Features and APIs
+* SDK Support for splunkd search API changes, for Splunk 9.0+. (Github PR [#189](https://github.com/splunk/splunk-sdk-java/pull/189))
+
+### Minor Changes
+* Automated docs generation using GitHub actions. (Github PR [#184](https://github.com/splunk/splunk-sdk-java/pull/184))
+
+## Version 1.8.0
+
+### New Features and APIs
+* Added a support to add custom headers in Service class. (Github PR [#176](https://github.com/splunk/splunk-sdk-java/pull/176)).
+* SSL Certificate validation (default implementation) added. (Github PR [#175](https://github.com/splunk/splunk-sdk-java/pull/175)).
+ * Boolean flag is introduced to skip/validate certificate. Use _HttpService.setValidateCertificates()_ to enable/disable certificate validation.
+ * Breaking change: Certificate validation is now enforced by default, for local or non-production use cases use _HttpService.setValidateCertificates(false)_.
+* Apps/app-install replaced with **apps/local**. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
+* Breaking change: HttpService.useTLS flag removed, please use _HttpService.setSslSecurityProtocol()_ to set a specific SSL/TLS implementation or else TLS v1.2 is used by default for Java 1.8.
+
+### Minor Changes
+
+* External Entities restricted in XML factory. (Github PR [#180](https://github.com/splunk/splunk-sdk-java/pull/180)).
+ * Prevent expansion of external entities in Document Builder factory.
+* Headers modified in Socket creation. (Github PR [#179](https://github.com/splunk/splunk-sdk-java/pull/179)).
+ * Http Request uses raw request headers by including escape characters which seems vulnerable. It was replaced with PrintWriter methods to avoid escape characters.
+ * Host parameter used in Socket is omitted to prevent exposing it to external users.
+* README.md file modified with all login methods along with Splunk Search creation example. (Github PR [#177](https://github.com/splunk/splunk-sdk-java/pull/177)).
+* Deploy plugin is removed from Splunk module pom to avoid redundancy. (Github PR [#172](https://github.com/splunk/splunk-sdk-java/pull/172)).
+* Setter methods for Session and Bearer token added along with test case. (Github PR [#171](https://github.com/splunk/splunk-sdk-java/pull/171))
+ * **Use:** service.setSplunkToken() for session tokens and service.setBearerToken() for long-lived tokens.
+* Modular input folder name renamed based on newer splunk folder name validation. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
+* SDK app collection URL has been updated to v1.1.0 in docker compose file. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
+ * Test files in sdk app collections are modified based on python v3 syntax.
+* Added Saved Search test case based on title. (Github PR [#166](https://github.com/splunk/splunk-sdk-java/pull/166))
+
+## Version 1.7.1
+
+### Minor Changes
+* Dependency breaking changes are resolved.
+
+## Version 1.7.0
+
+### New Features and APIs
+* Added Credits.md file along with licences. (Github PR [#162](https://github.com/splunk/splunk-sdk-java/pull/162)).
+* Improved TLS implementation as default behavior and turned on hostname verification for all hosts. (Github PR [#158](https://github.com/splunk/splunk-sdk-java/pull/158)).
+
+### Minor changes
+* Replaced Travis CI with Github actions (Github PR [#161](https://github.com/splunk/splunk-sdk-java/pull/161)).
+* Fixed Javadoc generation while project packaging. (Github PR [#159](https://github.com/splunk/splunk-sdk-java/pull/159)).
+* Fixed breaking change of **Index.getMaxHotBuckets()** method behavior to return as String instead of int.
+* SDK build is migrated from ant build tool to maven build tool (Github PR [#157](https://github.com/splunk/splunk-sdk-java/pull/157)).
+ * Dependencies directory for ant build is removed and maven dependencies are added using pom.xml.
+ * Dependencies are upgraded to its LTS version.
+ * Project structure is re-organized with respect to Maven.
+
+## Version 1.6.5
+
+### Bug Fixes
+
+* Fixed bug for push back buffer is full when exporting data in XML (GitHub PR [#125](https://github.com/splunk/splunk-sdk-java/pull/125)).
+
+## Version 1.6.4
+
+### Bug Fixes
+
+* Fixed bug in modinput Windows shims that caused Splunk Enterprise to fail to restart (GitHub PR [#120](https://github.com/splunk/splunk-sdk-java/pull/120)).
+* Fixed bug with data model endpoint on Splunk Enterprise 7+ (GitHub PR [#117](https://github.com/splunk/splunk-sdk-java/pull/117)).
+* Fixed bug with invalid `Index.submit()` forming an invalid REST API path for namespaced services ([#118](https://github.com/splunk/splunk-sdk-java/pull/118)).
+* Fixed bug with `Value.toDate(string value)` not being thread safe (GitHub PR [#109](https://github.com/splunk/splunk-sdk-java/pull/109)).
+
+## Version 1.6.3
+
+### New features and APIs
+
+* Added the `updated` property on all `Resource` objects (GitHub PR [#104](https://github.com/splunk/splunk-sdk-java/pull/104)).
+
+## Version 1.6.2
+
+### Bug Fixes
+
+* Update modular input shims to ensure Java processes are killed (GitHub issue [#92](https://github.com/splunk/splunk-sdk-java/issues/92)).
+
+## Version 1.6.1
+
+### Bug Fixes
+
+* Fix authentication issues when the Splunk `Set-Cookie` header is not the first one.
+
+## Version 1.6.0
+
+### New features and APIs
+
+* Added support for retrieving `Password` entities scoped by realm and username.
+* Added getter methods for embed `SavedSearch` properties.
+* Added support for custom `HttpURLConnection` connection timeouts on `HttpService`.
+* Performance improvement to `SavedSearch.dispatch()`.
+* Added getter methods to the `Job` class for retrieving `long` values (`getEventCountLong`, `getResultCountLong`, `getScanCountLong`).
+* Added `setFieldList()` to the `JobExportArgs` class.
+* Added support for the `manualRebuilds` `DataModel` setting.
+
+### Bug Fixes
+
+* Fixed `SavedSearch.Dispatch()` throwing a `NullPointerException` in some load-balanced search head clustering environments.
+* Fixed non-limit `PivotFilter` constructing the wrong JSON blob.
+
+### Minor changes
+
+* Added support for Travis CI.
+
+## Version 1.5.0
+
+### New features and APIs
+
+* Added support for cookie-based authentication, for Splunk 6.2+.
+
+### Bug Fixes
+
+* Fixed failure parsing XML responses. Pull Request #76.
+* Fixed bug where `Job` is never ready leading to infinite loops.
+
+### Minor changes
+
+* The SDK is now properly compiled with the `Command` class used in examples.
+
+## Version 1.4.0
+
+### New features and APIs
+
+* Added support for Java 8, when manually configuring the `Service` class to use TLSv1.2, TLSv1.1, or TLSv1 defined in the `SSLSecurityProtocol` enum. The default is still SSLv3.
+* Allow setting a custom `SSLSocketFactory` on the `HTTPService` and `Service` classes.
+
+### New examples
+
+* `ssl_protocols`: tries to connect to Splunk over HTTPS using different SSL/TLS protocols, then using a custom SSL and TLS `SSLSocketFactory`.
+
+### Minor changes
+
+* The SDK is now compiled with the `Command` class used in examples.
+
+## Version 1.3.2
+
+### Performance improvements
+
+* `Job` objects will only be refreshed by `isReady()` if the `Job` is not ready. This minimizes HTTP requests when getting properties of the `Job`.
+* The `Service` class now has a `getJob()` method that is used to retrieve a `Job` object by its sid String. This is better than calling `service.getJobs().get(sid)`, which has the overhead of getting all `Job` objects from Splunk in order to access a single `Job`.
+
+### New examples
+
+* `endpoint_instantiation`: shows how to manually instantiate any Splunk REST API endpoint.
+* `get_job`: shows how to get a `Job` by its sid using the new `Service.getJob()` method.
+
+### Minor changes
+
+* The `Entity` and `EntityCollection` classes each have a public constructor, so any Splunk endpoint can be manually instantiated.
+* The `FiredAlert` class now has a `getParsedExpirationTime()` method that returns a `Date` object.
+* Some test have been modified to work with the latest release of Splunk Enterprise (6.2.x).
+
+## Version 1.3.1
+
+* Removed deprecated functions from `DistributedConfiguration` class.
+* Oneshot searches, called from `Index.upload`, can now be passed search arguments.
+* Fixed a resource leak in the `Command.load` function.
+
+## Version 1.3
+
+### New features and APIs
+
+* Added support for data models and pivots.
+
+### Bug Fixes
+
+* When setting the sourcetype of a modular input event, events are indexed properly.
+ Previously Splunk would encounter an error and skip them. Also updated some of the modular input test data to reflect this change.
+* ResultsReaderXml now works with alternate XML parser libraries.
+
+## Version 1.2.2
+
+### Bug fixes
+
+* Hot fix to ResultsReaderXml to work with woodstox XML parsing library.
+
+## Version 1.2.1
+
+### New features and APIs
+
+* The Splunk Enterprise SDK for Java is fully compatible with Splunk Enterprise 6.0 as of this release.
+
+### Bug fixes
+
+* **JobCollection.create()** previously invalidated the collection and refreshed it to see whether the job had
+ appeared. This was problematic for Splunk Enterprise instances running many jobs at once. The method has been changed
+ to only interact with the endpoint specific to the newly created job.
+* Namespaces that contain special characters such as '@' in their owner or app are now handled correctly.
+
+### Breaking changes
+
+* Removed **Application.isManageable** and **Application.setManageable**, since they are deprecated or nonexistent
+ in all supported Splunk versions as of this release.
+* **OutputDefault.getMaxQueueSize** now returns a String instead of a long to match the behavior of
+ **setMaxQueueSize**.
+
+### Known issues
+
+* Certain combinations of requests and restarts of splunkd can cause splunkd to hang on OS X v10.8 Mountain Lion and
+ OS X v10.9 Mavericks running Splunk 6.0.0. This issue is not present when running Splunk Enterprise on earlier
+ versions of OS X. This will be fixed in a future release.
+
+* The modular input support in the Splunk Enterprise SDK for Java is not compatible with Windows Server 2003 or Windows Server
+ 2003 R2.
+
+## Version 1.2
+
+### New features and APIs
+
+* Added support for building modular input scripts in Java using the Splunk Enterprise SDK for Java.
+
+### Bug fixes
+
+* Any errors returned by Splunk in formats besides XML (for example, when Splunk returns JSON
+ if an error occurs during a search with output_mode=json), are passed on as is in the resulting
+ HttpException, replacing the uninformative error about XML parsing that was produced before.
+
+## Version 1.1
+
+### Breaking changes
+
+* The default setting for all search jobs is now `segmentation=none` unless
+ you explicitly set it otherwise. This setting returns results as a raw-text
+ string rather than a string in XML format.
+
+* The `ResultReaderCsv` class no longer supports streams from the `Service.export` method.
+ Instead, use the `ResultReaderXml` class with XML output, or use the `ResultReaderJson`
+ class with JSON output.
+
+### New features and APIs
+
+* New classes have been added, `MultiResultsReaderXml` and `MultiResultsReaderJson`,
+ to read search results streams with multiple result sets from `Service.Export` methods.
+
+* The `ResultsReader` classes now support `Iterable` and `Iterator` interfaces.
+
+* The `Event.getSegmentedRaw` method has been added to return raw data from events, preserving
+ segmentation information.
+
+### Bug fixes
+
+* The `ServiceInfo` class now uses the `services/*` endpoint rather than the
+ default namespace (`servicesNS/*`) for HTTP requests. This change is a workaround to
+ avoid a bug in Splunk that returns HTTP code 403 when the `server/info` endpoint
+ is accessed using certain namespaces.
+
+* The `ResultsReaderXml` class can now read search results streams from the
+ `Job.getResultsPreview` method.
+
+## Version 1.0
+
+### New features and APIs
+
+* Specialized *args* classes have been added to make it easier to pass
+ entity-specific arguments:
+ - `CollectionArgs`
+ - `IndexCollectionArgs`
+ - `JobArgs`
+ - `JobEventsArgs`
+ - `JobExportArgs`
+ - `JobResultsArgs`
+ - `JobResultsPreviewArgs`
+ - `JobSummaryArgs`
+ - `SavedSearchCollectionArgs`
+ - `SavedSearchDispatchArgs`
+
+ These new *args* classes are used with the following methods:
+ - `Service` constructor
+ - `Service.getSavedSearches` method
+ - `Service.getJobs` method
+ - `Service.getIndexes` method
+ - `Service.export` method
+ - `JobCollection.create` method
+ - `Job.getResults` method
+ - `Job.getResultsPreview` method
+ - `Job.getEvents` method
+ - `Job.getSummary` method
+ - `SavedSearch.dispatch` method
+
+* `ResultsReader.getNextEvent` now returns an `Event` object, which provides
+ better handling for multi-value fields. This change is backward-compatible
+ with older code that expects a `HashMap`. However this new
+ `Event` object is read-only.
+
+* Modular input functionality has been implemented (requiring Splunk 5.0+)
+ and the following classes have been added:
+ - `ModularInputKind`
+ - `ModularInputKindArgument`
+
+ The `InputCollection` class also now handles arbitrary input kinds represented
+ by modular inputs. You can call `InputCollection.getInputKinds` to get the set
+ of `InputKinds` on the connected Splunk instance.
+
+* The `ReceiverBehavior` interface has been added to work with output streams.
+
+* The `IndexCollection` class has been added as a specialized collection class
+ for indexes.
+
+* The `JobCollection` class has been added as a specialized collection class for
+ jobs.
+
+* You can now programatically remove indexes using the `IndexCollection.remove`
+ method (requires Splunk 5.0+).
+
+* You can now send data to an input using the `TcpInputs.attach`,
+ `TcpInputs.submit`, and `UdpInput.submit` convenience methods.
+
+* You can now restrict inputs to a specified host using the `setRestrictToHost`
+ method on `TcpInput`, `TcpSplunkInput`, and `UdpInput` (this method requires
+ Splunk 5.0+).
+
+* The `DistributedConfiguration.enable` and `DistributedConfiguration.disable`
+ convenience methods have been added, allowing you to immediately enable or
+ disable the configuration.
+
+* The following methods have been added to the `Index` class:
+ - `getBucketRebuildMemoryHint`
+ - `getMaxTimeUnreplicatedNoAcks`
+ - `getMaxTimeUnreplicatedWithAcks`
+ - `setBucketRebuildMemoryHint`
+ - `setMaxTimeUnreplicatedNoAcks`
+ - `setMaxTimeUnreplicatedWithAcks`
+
+### Breaking changes
+
+* The JAR files have changed so that everything is now included in the
+ **splunk.jar** file. The **splunk-external.jar** and **splunk-sdk.jar** files
+ have been removed.
+
+* Arguments are now submitted to Splunk in a consistent order, which improves
+ behavior in certain cases.
+
+* The `InputKind` enum is now a class. The `InputKind` class has static members
+ identical to the enum values, but you can no longer use a `switch` statement
+ over the values. Instead, use a series of `if-else` blocks. This change was
+ necessary to support arbitrary modular input kinds.
+
+* All text is now consistently UTF-8 encoded. Previously, the platform-native
+ encoding was used in certain cases. For example:
+ - HTTP requests are sent in UTF-8. In particular the values of *args*
+ classes are always encoded in UTF-8.
+ - Results and events from jobs are read as UTF-8.
+
+* The `Index.setAssureUTF8` method fails for Splunk 5.0+ because this field has
+ become a global setting rather than a per-index setting.
+
+* The `Index.clean` method now throws `SplunkException.INTERRUPTED` when
+ interrupted. Additionally, the `maxSeconds` parameter is obeyed more
+ accurately.
+
+* The `WindowsRegistryInput.getType` and `WindowsRegistryInput.setType` method
+ type has changed to `String[]` instead of `String`.
+
+* The `DistributedPeer.getBuild` method now returns an `int` instead of a
+ `String` to be consistent with the `ServiceInfo.getBuild` method.
+
+* The `setRestrictToHost` method on `TcpInput`, `TcpSplunkInput`, and `UdpInput`
+ throws an exception for Splunk 4.x. Previously, this method failed silently.
+
+* The `StormService` class has been removed, but will be restored in a
+ subsequent release.
+
+* The methods in the `ResultsReader` class now throw `IOException` instead of a
+ plain `Exception`, so callers no longer need to handle a plain `Exception`.
+
+* The `SplunkException` class now provides error messages when printed.
+
+* The test suite has been completely cleaned up, resulting in better coverage
+ and faster performance, mostly by eliminating unnecessary restarts. The test
+ suite strictly requires tests to handle restart requests.
+
+* The `get`, `remove`, and `contains` methods for entity collections now throw
+ an exception when a wildcarded namespace is passed, rather than incorrectly
+ returning an empty list or taking no action.
+
+* The `HashMap` and `Event` objects returned by `ResultsReader.getNextEvent` are
+ now read-only.
+
+* The `SavedSearch.getDispatchMaxTime` method previously returned a `String`,
+ but now returns an `int`.
+
+* The `LicensePool.getSlavesUsageBytes` method now returns a map from each slave
+ GUID to its license usage, instead of returning a `long`.
+
+* The `Service.oneshot` method has been renamed to `Service.oneshotSearch`.
+
+* The `Service.oneshot(String query, Map inputArgs, Map outputArgs)` overload
+ has been removed, because `outputArgs` had no effect.
+
+* The `SavedSearch.setArgsWildcard` method has been removed. To set a wildcard
+ parameter, specify it as a key-value pair in a map and pass it to the
+ `SavedSearch.dispatch(java.util.Map args)` method.
+
+* The `SavedSearch.setActionWildcard` method has been removed. Use the specific
+ setters to update these parameters.
+
+* The `SavedSearch.setDispatchWildcard` method has been removed. Use the
+ specific setters to update these parameters.
+
+* The `Service.getFiredAlerts` method has been renamed to
+ `getFiredAlertsGroups`.
+
+* The `Entity.reload` method has been removed.
+
+* The `Entity.toUpdate` field is no longer public.
+
+* The `Service.search(query)` and `Service.search(query, args)` methods now
+ return a search job instead of blocking and returning results.
+
+* The `Service.search(query, inputArgs, outputArgs)` overload has been removed.
+
+* The `OutputServer.setsslRootCAPPath` method has been renamed to
+ `setSslRootCAPPath`.
+
+* The `SavedSearch.getDispatchReduceFreq` method, which returned a `String`, has
+ been replaced with `getDispatchReduceFrequency`, which returns an `int`.
+
+* The `setRestrictToHost` method has been removed from the `TcpInput` and
+ `UdpInput` classes.
+
+* The `Settings.setMgmtHostPort` method has been renamed to `setMgmtPort` and
+ this method now returns an `int`.
+
+### Bug fixes
+
+* The `Service.versionCompare` method has been fixed to work as expected.
+
+* The `OutputDefault.update` method has been fixed so that when a "name"
+ parameter is not specified, the method no longer fails.
+
+### Deprecated features
+
+The following list contains the main features that have been deprecated (trivial
+changes are not included):
+
+* The public fields in the `ServiceArgs` class have been deprecated in favor of
+ the new setter methods to maintain consistency with the new *args* subclasses.
+
+* The `Application.isManageable` and `Application.setManageable` methods have
+ been deprecated in Splunk 5.0 and later.
+
+* The `DistributedConfiguration.getServerTimeout` method has been deprecated in
+ Splunk 5.0 and later.
+
+
+## Version 0.8.0 (beta)
+
+### Breaking changes
+
+* Changed how isDone() behaves with respect to job creation. Previously if a job
+ was not ready on the server, calling job.isDone() would cause an exception.
+ Now, calling isDone() will return false under the two following conditions:
+ 1) The job has not yet been scheduled. 2) The job has been scheduled but the
+ results are not ready. In addition, isDone() implicitly invokes job.refresh()
+ so the caller does not need to. This simplifies the code waiting for a job
+ result to this: (with a 500 millisecond polling interval)
+
+ ```
+ while (!job.isDone()) {
+ sleep(500);
+ }
+ ```
+
+* Added isReady() method to the Job class. This method detects whether or
+ not the job is ready to return data (i.e. be queried). It also implicitly
+ invokes job.refresh(). This allows for jobs with previews but that have not
+ necessarily completed to be accessed: (with a 500 millisecond polling
+ interval)
+
+ ```
+ while (!job.isReady()) {
+ sleep(500);
+ }
+ ```
+
+* All Job class accessors will call refresh once before accessing the object.
+
+### Bug fixes
+
+* Fixed ordering of collections when using pagination. Previously the order
+ could be random. Now it maintains the order of the entities returned by the
+ server.
+
+* Fixed XML streaming reader to properly work with paginated result sets.
+
+* Large collections can cause a default JVM to run out of memory: The Atom
+ parsing uses the streaming XML parser as opposed to a DOM parser.
+
+* Fixed Index class getSync() method to return an integer instead of a boolean.
+
+* Added Index class get method getEnableOnlineBucketRepair().
+
+* Added Index class get method getMaxBloomBackfillBucketAge().
+
+## Version 0.5.0 (preview)
+
+### New APIs
+* `StormService` class
+* `Receiver` class
+* `Upload` class
+* New setter methods for all classes
+* New getter methods for various classes
+
+### New features
+* Added support for a default index, allowing optional parameters
+ for streaming connections. The `Index` class now uses the new `Receiver`
+ class.
+
+* Added a paginate feature for Splunk return data. This feature allows for
+ `count` and `offset` methods to page through Splunk meta data instead of
+ retrieving all the data at once:
+
+ ```
+ ConfCollection confs;
+ Args args = new Args();
+ args.put("count", 30);
+ args.put("offset", 0);
+
+ confs = service.getConfs(args);
+ // ... operate on the first 30 elements
+ offset = offset + 30;
+ args.put("offset", offset)
+ confs = service.getConfs(args);
+ // ... operate on the next 30 elements
+ ```
+
+* Added a namespacing feature as optional arguments (`app`, `owner`, `sharing`)
+ to the collection's `create` and `get` methods. For more information about
+ namespaces, see
+ ["Overview of the Splunk Enterprise SDK for Java"](http://dev.splunk.com/view/java-sdk/SP-CAAAECN)
+ on the Developer Portal.
+
+ The following example shows how to use the optional namespace to restrict
+ creating and selecting saved searches to the namespace "owner = magilicuddy,
+ app = oneMeanApp":
+
+ ```
+ String searchName = "My scoped search";
+ String search = "index=main * | head 10";
+ args args = new Args();
+ args.put("owner", "magilicuddy");
+ args.put("app", "oneMeanApp");
+
+ // ... other creation arguments also get set into the args map
+
+ savedSearches.create(searchName, search, args);
+ ```
+
+ This example shows how to returns all saved searches within the same scoped
+ namespace:
+
+ ```
+ args args = new Args();
+ args.put("owner", "magilicuddy");
+ args.put("app", "oneMeanApp");
+ SavedSearchCollection
+ mySavedSearches = service.getSavedSearches(args);
+ ```
+
+* Added an XML, JSON, and CSV streaming results reader. This feature allows you
+ to retrieve event data using an incremental streaming mechanism. Return data
+ is in key-value pairs. The XML form uses built-in JDK XML parsing support. The
+ JSON and CSV form requires third-party JSON and CSV tokenizers, which are
+ included as ancillary .jar files in the SDK. The JSON and CSV streaming
+ results reader, which requires the external tokenizers, are contained in a
+ separate Splunk .jar file named `splunk-external.jar`.
+
+ The following example uses the built-in XML streaming reader:
+
+ ```
+ Job job = service.getJobs().create(query, queryArgs);
+ ...
+
+ HashMap map;
+ stream = job.getResults(outputArgs);
+ ResultsReader resultsReader = new ResultsReaderXml(stream);
+ while ((map = resultsReader.getNextEvent()) != null) {
+ for (String key: map.keySet())
+ System.out.println(key + " --> " + map.get(key));
+ }
+ ```
+
+* Added support for Splunk Storm. Instead of connecting to `Service`, you
+ connect to the new `StormService` class using similar arguments. Then, get a
+ `Receiver` object and log events. `StormService` requires the `index` key and
+ `sourcetype` parameters when sending events:
+
+ ```
+ // the storm token provided by Splunk
+ Args loginArgs = new Args("StormToken",
+ "p-n8SwuWEqPlyOXdDU4PjxavFdAn1CnJea9LirgTvzmIhMEBys6w7UJUCtxp_7g7Q9XopR5dW0w=");
+ Storm service = StormService.connect(loginArgs);
+
+ // get the receiver object
+ Receiver receiver = service.getReceiver();
+
+ // index and source type are required for storm event submission
+ Args logArgs = new Args();
+ logArgs.put("index", "0e8a2df0834211e1a6fe123139335741");
+ logArgs.put("sourcetype", "yoursourcetype");
+
+ // log an event.
+ receiver.log("This is a test event from the SDK", logArgs);
+ ```
+
+### Minor additions
+
+* Added a `genevents` example to generate events and push into Splunk using
+ various methods.
+* Added a second time format when parsing time. A second time format is required
+ to accommodate the `data/input/oneshot` endpoint that does not return a
+ standard time format and does not allow a time-format specifier.
+* Added a streaming reader to search examples. The main search example `search`
+ shows how to use all three result readers. There are build
+ modifications in build.xml to include the ancillary .jar files for JSON and
+ CSV.
+* Added an `Input` example to display Splunk inputs and their attributes.
+* Added an alias `log` for `submit` to the `Receiver` class.
+* Updated eclipse .classpath file, accounting for new additions.
+
+### Bug fixes
+
+* Fixed argument processing in the tail example.
+* Fixed timing window during search job creation; added `JOB_NOT_READY`
+ exception.
+* Fixed `Index` cleaning to require a timeout value; added `TIMEOUT` exception.
+* Fixed `LicensePool` type to use string quota instead of integer. This change
+ allows for `MAX` and `[M|G|T]`.
+* Fixed `action` when trying to update `Settings`.
+* Fixed user creation to force lowercase usernames.
+* Fixed the missing get methods for `ServiceInfo`.
+* Fixed a number of getter methods.
+
+## Version 0.1.0 (preview)
+
+Initial Splunk Enterprise SDK for Java release.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..26b75753
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,35 @@
+# Contributing Guidelines
+
+## How to contribute
+
+If you would like to contribute to this project, see [Contributions to Splunk](https://www.splunk.com/en_us/form/contributions.html) for more information.
+
+## Issues and bug reports
+
+If you're seeing some unexpected behavior with this project, please create an [issue](https://github.com/splunk/splunk-sdk-java/issues) on GitHub with the following information:
+
+1. Version of this project you're using (ex: 1.4.0)
+2. Platform version (ex: Windows Server 2012)
+3. Framework version (ex: Java 8)
+4. Splunk Enterprise version (ex: 8.0)
+5. Other relevant information (ex: local/remote environment, Splunk network configuration, standalone or distributed deployment, are load balancers used)
+
+Alternatively, if you have a Splunk question please ask on [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
+
+## Pull requests
+
+We love to see pull requests!
+
+To create a pull request:
+
+1. Fill out the [Individual Contributor Agreement](https://www.splunk.com/en_us/form/contributions.html).
+2. Fork the [repository](https://github.com/splunk/splunk-sdk-java).
+3. Make changes to the **develop** branch, preferably with tests.
+4. Create a [pull request](https://github.com/splunk/splunk-sdk-java/pulls) against the **develop** branch.
+
+## Contact us
+
+If you have a paid Splunk Enterprise or Splunk Cloud license, you can contact [Support](https://www.splunk.com/en_us/support-and-services.html) with questions.
+
+You can reach the Splunk Developer Platform team at _devinfo@splunk.com_.
+
diff --git a/CREDITS.md b/CREDITS.md
new file mode 100644
index 00000000..9afabf92
--- /dev/null
+++ b/CREDITS.md
@@ -0,0 +1,12 @@
+# Third-party software credits
+
+Some of the components included in the Splunk Enterprise SDK for Java are licensed under free or open source licenses. We wish to thank the contributors to those projects.
+
+| Contributor | Description | License |
+|:----------- |:----------- |:------- |
+| [opencsv](https://sourceforge.net/p/opencsv/source/ci/master/tree/) | For reading and writing CSV in Java | [Apache](https://github.com/splunk/splunk-sdk-java/blob/master/licenses/LICENSE-OPENCSV) |
+| [commons-cli](https://github.com/apache/commons-cli) | A package of Java utility classes for the classes that are in java.lang's hierarchy | [Apache](https://github.com/splunk/splunk-sdk-java/blob/master/licenses/LICENSE-COMMONS) |
+| [gson](https://github.com/google/gson) | Convert Java Objects into their JSON representation | [Apache](https://github.com/splunk/splunk-sdk-java/blob/master/licenses/LICENSE-GSON) |
+| [junit](https://github.com/junit-team/junit4) | Unit testing framework for Java | [Eclipse](https://github.com/splunk/splunk-sdk-java/blob/master/licenses/LICENSE-JUNIT) |
+| [jacoco](https://github.com/jacoco/jacoco) | JaCoCo runtime agent to your tests and allows basic report creation. | [Eclipse](https://github.com/splunk/splunk-sdk-java/blob/master/licenses/LICENSE-JACOCO) |
+| [netbeans-api](https://github.com/apache/netbeans) | OpenIDE Utilities | [Apache](https://github.com/splunk/splunk-sdk-java/blob/master/licenses/LICENSE-NETBEANS) |
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index d6456956..75b52484 100755
--- a/LICENSE
+++ b/LICENSE
@@ -1,202 +1,202 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..123c4cb1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,48 @@
+# text reset
+NO_COLOR=\033[0m
+# green
+OK_COLOR=\033[32;01m
+# red
+ERROR_COLOR=\033[31;01m
+# cyan
+WARN_COLOR=\033[36;01m
+# yellow
+ATTN_COLOR=\033[33;01m
+
+ROOT_DIR := $(shell git rev-parse --show-toplevel)
+
+VERSION := `git describe --tags --dirty 2>/dev/null`
+COMMITHASH := `git rev-parse --short HEAD 2>/dev/null`
+DATE := `date "+%FT%T%z"`
+
+.PHONY: all
+all: init test
+
+init:
+ @echo "$(ATTN_COLOR)==> init $(NO_COLOR)"
+
+.PHONY: test
+test:
+ @echo "$(ATTN_COLOR)==> test $(NO_COLOR)"
+# @ant test
+ @mvn test
+
+.PHONY: test_specific
+test_specific:
+ @echo "$(ATTN_COLOR)==> test_specific $(NO_COLOR)"
+ @sh ./scripts/test_specific.sh
+
+.PHONY: up
+up:
+ @echo "$(ATTN_COLOR)==> up $(NO_COLOR)"
+ @docker-compose up -d
+
+.PHONY: wait_up
+wait_up:
+ @echo "$(ATTN_COLOR)==> wait_up $(NO_COLOR)"
+ @for i in `seq 0 180`; do if docker exec -it splunk /sbin/checkstate.sh &> /dev/null; then break; fi; printf "\rWaiting for Splunk for %s seconds..." $$i; sleep 1; done
+
+.PHONY: down
+down:
+ @echo "$(ATTN_COLOR)==> down $(NO_COLOR)"
+ @docker-compose stop
diff --git a/README.md b/README.md
index 051bb373..8c63c07f 100644
--- a/README.md
+++ b/README.md
@@ -1,449 +1,414 @@
-# The Splunk Software Development Kit for Java (Preview Release)
+[](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml)
+# The Splunk Software Development Kit for Java
-This SDK contains library code and examples designed to enable developers to
-build applications using Splunk.
+#### Version 1.9.5
+
+The Splunk Software Development Kit (SDK) for Java contains library code and
+examples designed to enable developers to build applications using Splunk.
Splunk is a search engine and analytic environment that uses a distributed
-map-reduce architecture to efficiently index, search and process large
+map-reduce architecture to efficiently index, search and process large
time-varying data sets.
The Splunk product is popular with system administrators for aggregation and
-monitoring of IT machine data, security, compliance and a wide variety of
+monitoring of IT machine data, security, compliance and a wide variety of
other scenarios that share a requirement to efficiently index, search, analyze
and generate real-time notifications from large volumes of time series data.
-The Splunk developer platform enables developers to take advantage of the
+The Splunk developer platform enables developers to take advantage of the
same technology used by the Splunk product to build exciting new applications
that are enabled by Splunk's unique capabilities.
-## License
-The Splunk Software Development Kit for Java is licensed under the Apache
-License 2.0. Details can be found in the file LICENSE.
+## Getting started with the Splunk SDK for Java
-## This SDK is a Preview Release
+The Splunk SDK for Java contains library code and examples that show how to
+programmatically interact with Splunk for a variety of scenarios including
+searching, saved searches, data inputs, and many more, along with building
+complete applications.
-1. This Preview release is a pre-beta release. There will also be a beta
- release prior to a general release. It is incomplete and may have bugs.
+The information in this Readme provides steps to get going quickly, but for more
+in-depth information be sure to visit the
+[Splunk Developer Portal](http://dev.splunk.com/view/java-sdk/SP-CAAAECN).
-2. The Apache license only applies to the SDK and no other Software provided
- by Splunk.
+### Requirements
-3. Splunk in using the Apache license is not providing any warranties,
- indemnification or accepting any liabilities with the Preview SDK.
+Here's what you need to get going with the Splunk SDK for Java.
-4. Splunk is not accepting any Contributions to the Preview release of
- the SDK.
- All Contributions during the Preview SDK will be returned without review.
+#### Splunk
-## Getting started with the Splunk Java SDK
+If you haven't already installed Splunk, download it
+[here](http://www.splunk.com/download). For more about installing and running
+Splunk and system requirements, see
+[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 9.0 and 8.2.
-The Splunk Java SDK contains library code and examples that show how to
-programmatically interact with Splunk for a variety of scenarios including
-searching, saved searches, data inputs, and many more, along with building
-complete applications.
+#### Splunk SDK for Java
-### Requirements
+[Get the Splunk SDK for Java](http://dev.splunk.com/view/SP-CAAAECN)—download the SDK as a ZIP, then extract the files and build the SDK. Or, download the JAR and add it to your project.
-Here's what you need to get going with the Splunk Java SDK.
+If you want to contribute to the SDK, clone the repository from [GitHub](https://github.com/splunk/splunk-sdk-java).
-#### Splunk
-
-If you haven't already installed Splunk, download it here:
-http://www.splunk.com/download. For more about installing and running Splunk
-and system requirements, see Installing & Running Splunk
-(http://dev.splunk.com/view/SP-CAAADRV).
+#### Java using Maven
-#### Splunk Java SDK
+You can use [Apache Maven](http://maven.apache.org/) to build your Splunk SDK for Java projects. With a few updates to your project's `pom.xml` file, it will retrieve all necessary dependencies and seamlessly build your project.
-Get the Splunk Java SDK from GitHub (https://github.com/) and clone the
-resources to your computer. For example, use the following command:
+To add the Splunk SDK for Java `.JAR` file as a dependency:
-> git clone https://github.com/splunk/splunk-sdk-java.git
+1. Add the repository to your project's `pom.xml` file:
-#### Java and Ant
+```xml
+
+ ...
+
+ splunk-artifactory
+ Splunk Releases
+ http://splunk.jfrog.io/splunk/ext-releases-local
+
+
+```
-You'll need Java SE version 6 or higher, which you can download from the
-Oracle web site
-(http://www.oracle.com/technetwork/java/javase/downloads/index.html).
+2. Add the dependency to the `pom.xml` file:
-You'll also need Ant, which you can install from the Apache website
-(http://ant.apache.org/bindownload.cgi).
+```xml
+
+ ...
+
+ com.splunk
+ splunk
+ 1.9.5
+
+
+```
-If you are using Windows, you'll need to make sure the following system
-variables are created and set:
+Be sure to update the version number to match the version of the Splunk SDK for Java that you are using.
-* ANT_HOME should be set to the location where Ant is installed.
+> Note: You can make similar changes to use [Gradle](http://www.gradle.org/) as well.
-* JAVA_HOME should be set to the directory where the JDK is installed.
+### Building the SDK and documentation
-* PATH should include the path to the %ANT_HOME%\bin directory.
+To build the SDK, open a command prompt in the **/splunk-sdk-java**
+directory and enter:
-For full installation instructions, you can find more information here:
-
-* Java Platform Installation
- (http://www.oracle.com/technetwork/java/javase/index-137561.html)
+ mvn
-* Installing Apache Ant
- (http://ant.apache.org/manual/install.html)
+or
-### Building the SDK and documentation
+ mvn package
-To build the SDK, open a command prompt at the root of the Splunk Java SDK
-repository and enter:
+This command builds all of the .class and .jar files. If you just want to build
+the .class files, enter:
-> ant
+ mvn compile
To remove all build artifacts from the repository, enter:
-> ant clean
+ mvn clean
-To build the documentation for the SDK, enter:
+To build the documentation for the SDK, it is being automatically generated with mvn package, otherwise enter:
-> ant javadoc
+ cd splunk
+ mvn javadoc:javadoc
-If you are interested in more control of the build process, see the build.xml
-file. You can also type the following command from anywhere in the repository
-and Ant will find the root build file:
+### Usage
+#### Login using username and password
+```java
+import com.splunk.Service;
+import com.splunk.ServiceArgs;
-> ant {target} -find
+/**
+ * Login using username and password
+ */
+public class SplunkLogin {
-### Examples and unit tests
+ static Service service = null;
+ public static void main(String args[]) {
+ ServiceArgs loginArgs = new ServiceArgs();
+ loginArgs.setPort(8089);
+ loginArgs.setHost("localhost");
+ loginArgs.setScheme("https");
+ loginArgs.setUsername("USERNAME"); // Use your username
+ loginArgs.setPassword("PASSWORD"); // Use your password
+
+ // Initialize the SDK client
+ service = Service.connect(loginArgs);
+ }
+}
+```
+
+#### Login using Session Token
+```java
+import com.splunk.Service;
+import com.splunk.ServiceArgs;
+
+/**
+ * Login using Session token
+ */
+public class SplunkLogin {
+
+ static Service service = null;
+ /**
+ * Session Token.
+ * Actual token length would be longer than this token length.
+ */
+ static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";
+
+ public static void main(String args[]) {
+ ServiceArgs loginArgs = new ServiceArgs();
+ loginArgs.setPort(8089);
+ loginArgs.setHost("localhost");
+ loginArgs.setScheme("https");
+ loginArgs.setToken(String.format("Splunk %s", token));
+
+ // Initialize the SDK client
+ service = Service.connect(loginArgs);
+ }
+}
+```
+* Login using username and password will create Session token internally.
+* Login using Credentials (username & password) OR directly using Session token are similar.
+* In above two approaches, there is one limitation that expiration time of Session token cannot be extended. User has to re-login every time when token expires.
+* To overcome this limitation, **Authentication** token is used instead of Session token.
+* In **Authentication** token, user has a provision to set token expiration time. Splunk allows user to set relative/absolute time for token expiration.
+* In other words, **Authentication** token is configurable whereas Session token cannot be configured.
+
+#### Login using Authentication Token (RECOMMENDED)
+```java
+import com.splunk.Service;
+import com.splunk.ServiceArgs;
+
+/**
+ * Login using Authentication token
+ */
+public class SplunkLogin {
+
+ static Service service = null;
+ /**
+ * Authentication Token.
+ * Actual token length would be longer than this token length.
+ */
+ static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";
+
+ public static void main(String args[]) {
+ ServiceArgs loginArgs = new ServiceArgs();
+ loginArgs.setPort(8089);
+ loginArgs.setHost("localhost");
+ loginArgs.setScheme("https");
+ loginArgs.setToken(String.format("Bearer %s", token));
+
+ // Initialize the SDK client
+ service = Service.connect(loginArgs);
+ }
+}
+```
+
+#### Example of running a simple search by first creating the search job
+```java
+import com.splunk.Job;
+import com.splunk.ResultsReader;
+import com.splunk.ResultsReaderXml;
+import com.splunk.Service;
+import com.splunk.ServiceArgs;
+
+/**
+ * Logged in using Authentication token.
+ * Assuming that authentication token is already created from Splunk web.
+ * Create Job using search creation.
+ * Read results and print _raw fields
+ */
+public class SearchExample {
+
+ static Service service = null;
+
+ /**
+ * Authentication Token.
+ * Actual token length would be longer than this token length.
+ */
+ static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";
+
+ public static void main(String args[]) {
+
+ ServiceArgs loginArgs = new ServiceArgs();
+ loginArgs.setPort(8089);
+ loginArgs.setHost("localhost");
+ loginArgs.setScheme("https");
+ loginArgs.setToken(String.format("Bearer %s", token));
+
+ // Initialize the SDK client
+ service = Service.connect(loginArgs);
+
+ // Run a simple search by first creating the search job
+ Job job = service.getJobs().create("search index=_internal | head 10");
+
+ // Waiting for search results to be ready
+ while (!job.isReady()) {
+ try {
+ Thread.sleep(500); // 500 ms
+ } catch (Exception e) {
+ // Handle exception here.
+ }
+ }
-The Splunk Java SDK includes several examples and unit tests that are run at
-the command line.
+ // Read results
+ try {
+ ResultsReader reader = new ResultsReaderXml(job.getEvents());
+ // Iterate over events and print _raw field
+ reader.forEach(event -> System.out.println(event.get("_raw")));
+
+ } catch (Exception e) {
+ // Handle exception here.
+ }
+ }
+}
+```
+
+For more information on authentication using tokens, please visit [Splunk Docs](https://docs.splunk.com/Documentation/Splunk/latest/Security/Setupauthenticationwithtokens).
+
+### Unit tests
+
+The Splunk SDK for Java includes several unit tests that are run at
+the command line.
#### Set up the .splunkrc file
-To connect to Splunk, many of the SDK examples and unit tests take command-
-line arguments that specify values for the host, port, and login credentials
-for Splunk. For convenience during development, you can store these arguments
-as key-value pairs in a text file named .splunkrc. Then, when you don't
-specify these arguments at the command line, the SDK examples and unit tests
-use the values from the .splunkrc file.
+To connect to Splunk, many of the SDK examples and unit tests take command-line
+arguments that specify values for the host, port, and login credentials for
+Splunk. For convenience during development, you can store these arguments as
+key-value pairs in a text file named **.splunkrc**. Then, the SDK examples and
+unit tests use the values from the **.splunkrc** file when you don't specify
+them.
-To use a .splunkrc file, create a text file with the following format:
+To use this convenience file, create a text file with the following format:
- # Host at which Splunk is reachable (OPTIONAL)
+ # Splunk host (default: localhost)
host=localhost
- # Port at which Splunk is reachable (OPTIONAL)
- # Use the admin port, which is 8089 by default.
+ # Splunk admin port (default: 8089)
port=8089
# Splunk username
username=admin
# Splunk password
password=changeme
- # Access scheme (OPTIONAL)
+ # Access scheme (default: https)
scheme=https
- # Application context (OPTIONAL)
- app=MyApp
- # Owner context (OPTIONAL)
- owner=User1
+ # Your version of Splunk (default: 5.0)
+ version=5.0
-Save the file as .splunkrc in the current user's home directory.
+Save the file as **.splunkrc** in the current user's home directory.
-* For example on Mac OS X, save the file as:
+* For example, on Mac OS X, save the file as:
- > ~/.splunkrc
+ ~/.splunkrc
-* On Windows, save the file as:
+* On Windows, save the file as:
- > C:\Users\currentusername\\.splunkrc
+ C:\Users\currentusername\.splunkrc
You might get errors in Windows when you try to name the file because
".splunkrc" looks like a nameless file with an extension. You can use
- the command line to create this file--go to the
- C:\Users\currentusername directory and enter the following command:
-
- > Notepad.exe .splunkrc
-
- Click Yes, then continue creating the file.
+ the command line to create this file—go to the
+ **C:\Users\currentusername** directory and enter the following command:
-NOTE: Storing login credentials in the .splunkrc file is only for convenience
-during development—this file isn't part of the Splunk platform and
-shouldn't be used for storing user credentials for production. And, if you're
-at all concerned about the security of your credentials, just enter them at
-the command line rather than saving them in the .splunkrc file.
+ Notepad.exe .splunkrc
+ Click **Yes**, then continue creating the file.
-#### Run examples
-
-After you build the SDK, examples are put in the splunk-sdk-
-java/dist/examples directory. To run the examples, run the Java interpreter
-at the command line using the -jar flag to specify the target example jar
-file, and include any arguments that are required by the example. To get help
-for an example, use the --help argument with an example.
-
-For example, to see the command-line arguments for the Search example, open a
-command prompt in the splunk-sdk-java directory and enter:
-
-> java -jar dist/examples/search.jar --help
-
-To run the Search example, open a command prompt in the splunk-sdk-java
-directory and enter:
-
-> java -jar dist/examples/search.jar "search * | head 10" --output_mode=csv
-
-There is also a helper script called run in the root of the repository that
-simplifies running the SDK examples. For example, on Mac OS X you could
-simply enter:
-
-> ./run search "search * | head 10" --output_mode=csv
+**Note**: Storing login credentials in the **.splunkrc** file is only for
+convenience during development. This file isn't part of the Splunk platform and
+shouldn't be used for storing user credentials for production. And, if you're
+at all concerned about the security of your credentials, just enter them at
+the command line rather than saving them in this file.
#### Run unit tests
-To run the SDK unit tests, open a command prompt at the root of the Splunk
-Java SDK repository and enter:
+To run the SDK unit tests, open a command prompt in the **/splunk-sdk-java**
+directory and enter:
-> ant test
+ mvn test
-To run the units from anywhere in the repository, enter:
+You can also run specific test classes by passing the class to the -Dtest=
+option, e.g.,
-> ant test -find
+ mvn test -Dtest=AtomFeedTest
-It's also possible to run the units within Java IDEs such as IntelliJ and
-Eclipse. For example, to open the Splunk Java SDK project in Eclipse:
-1. Click File, Import.
-2. Click General, Existing Projects into Workspace, then click Next.
-3. In Select root directory, type the path to the Splunk Java SDK root
- directory (or click Browse to locate it), then click Finish.
+The maven configuration can also produce an HTML report of all the tests automatically when **mvn package / mvn test** are executed.
+Alternate way to generate report is using below command under splunk directory:
-## The Splunk Java SDK components
+ mvn jacoco:report
-The Splunk developer platform consists of three primary components: splunkd,
-the engine; splunkweb, the app framework that sits on top of the engine; and
-the Splunk SDKs that interface with the REST API and extension points.
+The report will be written in **/splunk-sdk-java/splunk/target/site/surefire-report.html**.
-The Splunk Java SDK lets you target splunkd by making calls against the
-engine's REST API and accessing the various splunkd extension points such as
-custom search commands, lookup functions, scripted inputs, and custom REST
-handlers.
+It's also possible to run the units within Java IDEs such as IntelliJ and
+Eclipse. For example, to open the Splunk SDK for Java project in Eclipse:
-For more information about the API, see the Splunk Java SDK documentation
-(http://splunk.github.com/splunk-sdk-java/docs/0.1.0/index.html).
+1. Click **File**, **Import**.
+2. Click **General**, **Existing Projects into Workspace**, then click
+ **Next**.
+3. In **Select root directory**, type the path to the Splunk SDK for Java root
+ directory (or click **Browse** to locate it), then click **Finish**.
-### Service
+#### Measure code coverage
-The Service class is the primary entry point for the client library.
-Construct an instance of the Service class and provide any arguments that are
-required to connect to an available Splunk server. Once the Service instance
-is created, call the login() method and provide login credentials. Once you
-have an authenticated Service instance, you can use it to navigate,
-enumerate, and operate on a wide variety of Splunk resources. You can also
-use it to issue searches and make REST API calls.
+Measurement of code coverage is generated along with mvn package / mvn test:
-The following example creates a Service instance and prints the Splunk
-version number:
+ mvn jacoco:report
- import com.splunk.Service;
-
- public class Program {
- public static void run(String[] args) {
- Service service = new Service("localhost", 8089);
- service.login("admin", "changeme");
- ServiceInfo serviceInfo = service.getInfo();
- System.out.println(serviceInfo.getVersion());
- }
- }
-
-The Service class provides a variety of constructor overloads to handle
-various scenarios that require different combinations of arguments. In the
-most general case, the Service class takes a map of arguments, which
-simplifies passing large and varying combinations of arguments, as shown in
-the following example:
-
- Map args = new HashMap();
- args.put("host", "localhost");
- args.put("port", 8089);
- Service service = new Service(args);
- service.login("admin", "changeme");
-
-The Service class also provides a static helper method that takes a map and
-combines the construction and authentication of the instance into a single
-call. Because of its flexibility, it is the method that is used most often in
-the SDK examples and unit tests. The following example shows how to use this
-helper method:
-
- Map args = new HashMap();
- args.put("host", "localhost");
- args.put("port", 8089);
- args.put("scheme", "https");
- args.put("app", "MyApp");
- args.put("owner", "nobody");
- args.put("username", "admin");
- args.put("password", "changeme");
- Service service = Service.connect(args);
-
-### Entities and collections
-
-The Splunk REST API consists of over 160 endpoints that provide access to
-almost every feature of Splunk. The majority of the Splunk Java SDK API
-follows a convention of exposing resources as collections of entities, where
-an entity is a resource that has properties, actions, and metadata that
-describes the entity. The entity/collection pattern provides a consistent
-approach to interacting with resources and collections of resources.
-
-For example, the following code prints all Splunk users:
-
- Service service = Service.connect(...);
- for (User user : service.getUsers().values())
- System.out.println(user.getName());
-
-Similarly, the following code prints all the Splunk apps:
-
- Service service = Service.connect(...);
- for (Application app : service.getApplications().values())
- System.out.println(app.getName());
-
-Collections use a common mechanism to create and remove entities. Entities
-use a common mechanism to retrieve and update property values, and access
-entity metadata. Once you're familiar with this pattern, you'll have a
-reasonable understanding of how the SDK and underlying REST API work.
-
-The SDK contains the base classes Entity and EntityCollection, both of which
-derive from the common base class Resource. Note that Service is not a
-Resource, but is a container that provides access to all features associated
-with a Splunk instance.
-
-The class hierarchy for the core SDK library is as follows:
-
- Service
- Resource
- Entity
- ResourceCollection
- EntityCollection
-
-### Client state
-
-Instances of the Resource class maintain a client-side copy of the state of
-the corresponding Splunk resource. For example, an entity will have a copy of
-its properties, and a collection will have a copy of its members. When you
-request a property (or collection member), the local copy is returned if it's
-available. Otherwise, a new copy is requested from the server if it's not
-available or if the local copy is known to be out of date (for example, when
-the update method was just called).
-
-Note: In general, there is no way to determine whether your local client
-state is in sync with the server other than forcing a refresh of the
-corresponding Resource instance.
-
-The Resource class provides the following methods for managing client-side
-state:
-
-* The `refresh` method unconditionally refreshes the client state for the
- object.
-
-* The `invalidate` method marks the local state as invalid, and it is
- refreshed the next time the object's state is accessed.
-
-* The `validate` method checks whether the local state has been marked
- invalid and calls the refresh method if necessary.
-
-
-### Search
-
-One of the primary features of Splunk is running searches and retrieving
-search results. The following code example shows how to create a search job,
-poll for completion, and retrieve the result stream:
-
- Service service = Service.connect(...);
- Job job = service.getJobs().create("search * | head 10")
- while (!job.isDone()) {
- Thread.sleep(2000);
- job.refresh();
- }
- InputStream stream = job.getResults();
-
-The SDK API has many features such as real-time search, numerous search
-options, various types of search results, and the ability to execute
-synchronous and asynchronous search requests. To explore core search
-features, see the Search example included in the SDK.
+To view the coverage report, open
+**/splunk-sdk-java/splunk/target/test-report/index.html** in your web browser.
## Repository
-
build
-
This directory is created by the build and contains intermediate build
+
/argsGenerator
+
This directory is created by the build and contains intermediate build
ouputs
-
dist
-
This directory is created by the build and contains final build
-outputs
-
-
-
-
docs
-
Documentation
-
-
-
-
examples
-
Examples demonstrating various SDK features
-
-
-
-
lib
-
3rd party libraries used by examples and unit tests
+
/splunk/target
+
This directory is created by the build and contains intermediate build
+ouputs
-
splunk
+
/splunk/src/main
Source for com.splunk
-
splunk-sdk
-
Source for com.splunk.sdk, utilities shared by examples and
-units
-
-
-
-
tests
+
/splunk/src/test
Source for unit tests
+
### Changelog
-The file CHANGELOG.md in the root of the repository contains a description
-of changes for each version of the SDK. You can also find it online at:
-
-* https://github.com/splunk/splunk-sdk-java/blob/master/CHANGELOG.md
+The **CHANGELOG.md** file in the root of the repository contains a description
+of changes for each version of the SDK. You can also find it online at
+[https://github.com/splunk/splunk-sdk-java/blob/master/CHANGELOG.md](https://github.com/splunk/splunk-sdk-java/blob/master/CHANGELOG.md).
### Branches
-The `master` branch always represents a stable and released version of the
-SDK.
-You can read more about our branching model on our Wiki:
-
-* https://github.com/splunk/splunk-sdk-java/wiki/Branching-Model
-
-## Resources
-
-You can find anything having to do with developing on Splunk at the Splunk
-developer portal:
-
-* http://dev.splunk.com
+The **master** branch always represents a stable and released version of the SDK.
+You can read more about our branching model on our Wiki at
+[https://github.com/splunk/splunk-sdk-java/wiki/Branching-Model](https://github.com/splunk/splunk-sdk-java/wiki/Branching-Model).
-For Splunk Java SDK reference documentation, see:
+## Documentation and resources
-* http://splunk.github.com/splunk-sdk-java/docs/0.1.0/index.html
+If you need to know more:
-You can also find reference documentation for the REST API:
+* For all things developer with Splunk, your main resource is the [Splunk Developer Portal](http://dev.splunk.com).
-* http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI
+* For conceptual and how-to documentation, see the [Overview of the Splunk SDK for Java](http://dev.splunk.com/view/SP-CAAAECN).
-For an introduction to the Splunk product and some of its capabilities:
+* For API reference documentation, see the [Splunk SDK for Java Reference](http://docs.splunk.com/Documentation/JavaSDK).
-* http://docs.splunk.com/Documentation/Splunk/latest/User/SplunkOverview
+* For more about the Splunk REST API, see the [REST API Reference](http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI).
-For more information on the SDK and this repository check out our GitHub Wiki
+* For more about about Splunk in general, see [Splunk>Docs](http://docs.splunk.com/Documentation/Splunk).
-* https://github.com/splunk/splunk-sdk-java/wiki/
+* For more about this SDK's repository, see our [GitHub Wiki](https://github.com/splunk/splunk-sdk-java/wiki/).
## Community
@@ -452,46 +417,72 @@ Stay connected with other developers building on Splunk.
-
Email
+
Email
devinfo@splunk.com
-
Issues
+
Issues
https://github.com/splunk/splunk-sdk-java/issues/
-
Answers
+
Answers
http://splunk-base.splunk.com/tags/java/
-
Blog
+
Blog
http://blogs.splunk.com/dev/
-
Twitter
+
Twitter
@splunkdev
+
### How to contribute
-We aren't ready to accept code contributions yet, but will be shortly. Check
-this README for more updates soon.
+If you would like to contribute to the SDK, go here for more information:
+
+* [Splunk and open source](http://dev.splunk.com/view/opensource/SP-CAAAEDM)
+
+* [Individual contributions](http://dev.splunk.com/goto/individualcontributions)
+
+* [Company contributions](http://dev.splunk.com/view/companycontributions/SP-CAAAEDR)
### Support
-* SDKs in Preview will not be Splunk supported. Once the Java SDK moves to an
- Open Beta we will provide more detail on support.
+1. You will be granted support if you or your company are already covered
+ under an existing maintenance/support agreement. Send an email to
+ _support@splunk.com_ and include "Splunk SDK for Java" in the subject line.
+
+2. If you are not covered under an existing maintenance/support agreement, you
+ can find help through the broader community at:
+
+
+
Splunk Answers (use
+ the sdk, java, python, and javascript tags to
+ identify your questions)
+3. Splunk will NOT provide support for SDKs if the core library (the
+ code in the splunk directory) has been modified. If you modify an SDK
+ and want support, you can find help through the broader community and Splunk
+ answers (see above). We would also like to know why you modified the core
+ library—please send feedback to _devinfo@splunk.com_.
+4. File any issues on [GitHub](https://github.com/splunk/splunk-sdk-java/issues).
-* Issues should be filed here:
- https://github.com/splunk/splunk-sdk-java/issues
### Contact Us
-You can reach the Dev Platform team at devinfo@splunk.com
+You can reach the Developer Platform team at _devinfo@splunk.com_.
+
+## License
+The Splunk Java Software Development Kit is licensed under the Apache
+License 2.0. Details can be found in the LICENSE file.
diff --git a/argsGenerator/README.md b/argsGenerator/README.md
new file mode 100644
index 00000000..a0294583
--- /dev/null
+++ b/argsGenerator/README.md
@@ -0,0 +1,128 @@
+# Args Class Generator
+
+This tool generates custom `Args` subclasses based on the REST API documentation for the associated endpoint.
+
+
+## Example Usage
+
+```
+./gen_args_class.py < specs/JobArgs_POST__search_jobs.argspec > Output.java
+```
+
+
+## Quickstart
+
+For each class that you want to generate, an `.argspec` file must be created that defines the specific parameters supported by the Args class, along with its Java datatype and documentation.
+
+For example, the specification:
+
+```
+auto_cancel
+AutoCancel
+int
+Sets the number of seconds of inactivity after which to automatically cancel a job. A value of 0 means never auto-cancel.
+-
+The number of seconds after which to cancel a job.
+===
+```
+
+...generates the following code:
+
+```
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the number of seconds of inactivity after which to automatically cancel a job. A value of 0 means never auto-cancel.
+ *
+ * @param autoCancel
+ * The number of seconds after which to cancel a job.
+ */
+ public void setAutoCancel(int autoCancel) {
+ this.put("auto_cancel", autoCancel);
+ }
+
+ /* END AUTOGENERATED CODE */
+```
+
+Notice that the generator does not generate an entire class, but rather only its methods.
+The user must manually:
+
+* Create the class definition and documentation.
+* Add the constructor.
+* Add any nested `enum` types that the generated setters require.
+
+
+## Argument Specification Format
+
+Any line that begins with `#` is a comment and will be ignored. Blank lines are significant (and are not ignored).
+
+Any line at the beginning of the file that begins with `!` is a directive and will change the behavior of the generator. For example:
+
+```
+# Some arguments are defined multiple times by different copied sections.
+# Ignore errors related to this. The first version wins.
+!SET ignore_duplicates 1
+```
+
+The rest of the file is a series of argument definitions:
+
+```
+<< machine name >>
+<< Java name (upper camelcase) >>
+<< Java type >>
+<< method description line #1 >>
+<< method description line .. >>
+<< method description line #n >>
+-
+<< parameter description line #1 >>
+<< parameter description line .. >>
+<< parameter description line #n >>
+===
+```
+
+Note that the last specification must still end with a `===` line.
+
+### Special Java Types
+
+A few values for `<< Java type >>` are handled specially:
+
+* `String[]-MULTIPLE` - Each value will be a separate parameter.
+ * For example "f = {1,2,3}" would appear as `f=1&f=2&f=3` in the final URL.
+* `String[]-CSV` - Values will be submitted as a single comma-separated parameter.
+ * For example "f = {1,2,3}" would appear as `f=1,2,3` in the final URL.
+
+### Custom Setter Code
+
+For more complex cases where the generated accessor is not appropriate (like the Java type `Date`), you can also specify custom code for an argument by adding a `!CODE` line after the argument description and follow that line with custom Java code.
+
+For example:
+
+```
+dispatch.earliest_time
+DispatchEarliestTime
+Date
+Sets the earliest time for this search.
+-
+A date that specifies the earliest time for this search.
+!CODE
+ String javaFormatString = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ String timeString = new SimpleDateFormat(javaFormatString).format(dispatchEarliestTime);
+ this.put("dispatch.earliest_time", timeString);
+===
+```
+
+...generates this code:
+
+```
+ /**
+ * Sets the earliest time for this search.
+ *
+ * @param dispatchEarliestTime
+ * A date that specifies the earliest time for this search.
+ */
+ public void setDispatchEarliestTime(Date dispatchEarliestTime) {
+ String javaFormatString = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ String timeString = new SimpleDateFormat(javaFormatString).format(dispatchEarliestTime);
+ this.put("dispatch.earliest_time", timeString);
+ }
+```
\ No newline at end of file
diff --git a/argsGenerator/gen_args_class.py b/argsGenerator/gen_args_class.py
new file mode 100755
index 00000000..a5c3d720
--- /dev/null
+++ b/argsGenerator/gen_args_class.py
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+
+import sys
+
+input = sys.stdin
+output = sys.stdout
+
+
+def read_line():
+ """
+ Returns the next line from the input, including the EOL sequence.
+ Throws StopIteration on EOF.
+
+ Skips comment lines automatically.
+ """
+ while True:
+ line = next(input)
+ if line.startswith('#'):
+ continue
+ return line
+
+
+def lowercase_first_letter(string):
+ return string[0].lower() + string[1:]
+
+
+output.write(""" /* BEGIN AUTOGENERATED CODE */
+
+""")
+
+ignore_duplicates = False
+args_already_seen = set()
+ignored_machine_names = set()
+
+try:
+ while True:
+ machine_name = read_line()[:-1]
+ if machine_name.startswith('!'):
+ # Actually this is a directive. Process it.
+ directive = machine_name
+ if directive == '!SET ignore_duplicates 1':
+ ignore_duplicates = True
+ elif directive.startswith('!SUPPRESS '):
+ machine_name = directive[len('!SUPPRESS '):]
+ ignored_machine_names.add(machine_name)
+ else:
+ sys.exit("Unknown directive: %s" % directive)
+ continue
+ java_name = read_line()[:-1]
+ type = read_line()[:-1]
+
+ description_lines = []
+ reading_description = True
+ code_lines = None
+ while True:
+ line = read_line()
+ if line.startswith('!CODE'):
+ code_lines = []
+ reading_description = False
+ continue
+ if line.startswith('='):
+ break
+
+ if reading_description:
+ description_lines.append(line)
+ else:
+ code_lines.append(line)
+
+ if not java_name[0].isupper():
+ sys.exit("Expected first letter to be uppercase: %s" % java_name)
+ java_name_lower = lowercase_first_letter(java_name)
+
+ # Generate the setter code
+ if code_lines is not None:
+ # Custom code for this setter
+ code = ''.join(code_lines)[:-1];
+ else:
+ # Standard code for this setter, depending on its parameter type
+ code = """ this.put("%s", %s);""" % (machine_name, java_name_lower)
+ if '[]' in type or type == 'Date':
+ if type == 'String[]-MULTIPLE':
+ type = 'String[]'
+ code = """ this.put("%s", %s);""" % (machine_name, java_name_lower)
+ elif type == 'String[]-CSV':
+ type = 'String[]'
+ code = """ StringBuilder csv = new StringBuilder();
+ for (int i = 0, n = %s.length; i < n; i++) {
+ if (i != 0) {
+ csv.append(",");
+ }
+ csv.append(%s[i]);
+ }
+
+ this.put("%s", String.valueOf(csv));""" % (java_name_lower, java_name_lower, machine_name)
+ else:
+ sys.exit("Don't know how to encode an array of type: %s" % type);
+
+ # Split description_lines -> {method_description_lines, param_description_lines}
+ method_description_lines = []
+ param_description_lines = []
+ saw_description_separator = False
+ for line in description_lines:
+ if line.startswith('-'):
+ saw_description_separator = True
+ continue
+
+ if not saw_description_separator:
+ method_description_lines.append(line)
+ else:
+ param_description_lines.append(line)
+
+ if not saw_description_separator:
+ print ('WARNING: No separate method description found for ' +
+ 'argument %s. This is against convention.') % machine_name
+ param_description_lines = method_description_lines
+ method_description_lines = []
+
+ # Format method_description_lines
+ method_description_formatted = ''
+ if method_description_lines != []:
+ for line in method_description_lines:
+ method_description_formatted += ' * %s' % line
+ method_description_formatted += ' * \n'
+
+ # Format param_description_lines
+ param_description_formatted = ''
+ for line in param_description_lines:
+ param_description_formatted += ' * %s' % line
+
+ cur_arg = (machine_name, type)
+ if cur_arg in args_already_seen:
+ if ignore_duplicates:
+ continue
+ else:
+ sys.exit("Multiple definitions for argument: %s %s" % (
+ type, machine_name));
+ else:
+ args_already_seen.add(cur_arg)
+
+ # Output the current argument
+ if machine_name not in ignored_machine_names:
+ output.write(""" /**
+%s * @param %s
+%s */
+ public void set%s(%s %s) {
+%s
+ }
+
+""" % (method_description_formatted,
+ java_name_lower, param_description_formatted,
+ java_name, type, java_name_lower,
+ code))
+
+except StopIteration:
+ # Done!
+ pass
+
+output.write(""" /* END AUTOGENERATED CODE */
+""")
\ No newline at end of file
diff --git a/argsGenerator/specs/CollectionArgs__GET_collection.argspec b/argsGenerator/specs/CollectionArgs__GET_collection.argspec
new file mode 100644
index 00000000..01d52797
--- /dev/null
+++ b/argsGenerator/specs/CollectionArgs__GET_collection.argspec
@@ -0,0 +1,63 @@
+app
+App
+String
+Sets the app context in which to list the collection.
+-
+The app context in which to list the collection. A {@code null} value indicates no app context, and a value of {@code "-"} indicates an app wildcard.
+===
+owner
+Owner
+String
+Sets the owner context in which to list the collection.
+-
+The owner context in which to list the collection. A value of {@code "-"} indicates a wildcard, and a {@code null} value indicates no owner context.
+===
+sharing
+Sharing
+String
+Sets the sharing context in which to list the collection.
+-
+The sharing context in which to list the collection. Valid values are "user", "app", "global", and "system".
+===
+count
+Count
+int
+Sets the maximum number of entries to return.
+-
+The maximum number of entries to return. To return all entries, specify 0.
+===
+offset
+Offset
+int
+Sets the index of the first entry to return.
+-
+The index of the first entry to return.
+===
+search
+Search
+String
+Sets a search query to filter the response. The response matches field values against the search query. For example, "foo" matches any object that has "foo" as a substring in a field, and "field_name=field_value" restricts the match to a single field.
+-
+A search query to filter the response.
+===
+sort_dir
+SortDirection
+SortDirection
+Sets the direction to sort entries.
+-
+The sorting order--ascending or descending.
+===
+sort_key
+SortKey
+String
+Sets the field to use for sorting.
+-
+The field to sort by.
+===
+sort_mode
+SortMode
+SortMode
+Sets the mode to use for sorting.
+-
+The collating sequence for sorting entries.
+===
diff --git a/argsGenerator/specs/IndexCollectionArgs__GET_data_indexes.argspec b/argsGenerator/specs/IndexCollectionArgs__GET_data_indexes.argspec
new file mode 100644
index 00000000..4b073d67
--- /dev/null
+++ b/argsGenerator/specs/IndexCollectionArgs__GET_data_indexes.argspec
@@ -0,0 +1,17 @@
+count
+Count
+int
+Sets the maximum number of entries to return.
+-
+The maximum number of entries to return. To return all entries, specify -1.
+!CODE
+ super.setCount(count);
+===
+summarize
+Summarize
+boolean
+Sets whether to omits certain index details to provide a faster response.
+-
+{@code true} to omit index details for a faster response,
+{@code false} if not.
+===
diff --git a/argsGenerator/specs/JobArgs__POST_search_jobs.argspec b/argsGenerator/specs/JobArgs__POST_search_jobs.argspec
new file mode 100644
index 00000000..3b00c1af
--- /dev/null
+++ b/argsGenerator/specs/JobArgs__POST_search_jobs.argspec
@@ -0,0 +1,206 @@
+# NOTE: Large sections of this specification have been copied to
+# JobExportArgs__GET_search_jobs_export.argspec, which should be
+# updated (and regenerated) to reflect changes made to this file.
+#
+auto_cancel
+AutoCancel
+int
+Sets the number of seconds of inactivity after which to automatically cancel a job. A value of 0 means never auto-cancel.
+-
+The number of seconds after which to cancel a job.
+===
+auto_finalize_ec
+AutoFinalizeEventCount
+int
+Sets the number of events to process after which to auto-finalize the search. A value of 0 means no limit.
+-
+The number of events.
+===
+auto_pause
+AutoPause
+int
+Sets the number of seconds of inactivity after which to automatically pause a job. A value of 0 means never auto-pause.
+-
+The number of seconds after which to pause.
+===
+# TODO: Make Date version.
+earliest_time
+EarliestTime
+String
+Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The earliest time.
+===
+enable_lookups
+EnableLookups
+boolean
+Indicates whether to enable lookups for this search. Enabling lookups might slow searches significantly depending on the nature of the lookups.
+-
+{@code true} to enable lookups, {@code false} if not.
+===
+exec_mode
+ExecutionMode
+ExecutionMode
+Sets the type of search to run ("blocking", "oneshot", or "normal").
+-
+The search type.
+===
+force_bundle_replication
+ForceBundleReplication
+boolean
+Specifies whether this search should cause (and wait depending on the value of {@code setSynchronizeBundleReplication}) bundle synchronization with all search peers.
+-
+{@code true} if this search should cause bundle synchronization,
+{@code false} if not.
+===
+id
+Id
+String
+Sets a search ID (SID). If unspecified, a random ID is generated.
+-
+The search ID.
+===
+# TODO: Make Date version.
+latest_time
+LatestTime
+String
+Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The latest time.
+===
+max_count
+MaximumCount
+int
+Sets the number of events that can be accessible in any given status bucket. Also, in transforming mode, this sets the maximum number of results to store. Specifically, in all calls, {@code codeoffset + count <= max_count}.
+-
+The maximum count of events.
+===
+max_time
+MaximumTime
+int
+Sets the maximum number of seconds to run this search before finalizing. Specify 0 to never finalize.
+-
+The maximum time, in seconds.
+===
+namespace
+Namespace
+String
+Specifies the application namespace to which to restrict searches.
+-
+The namespace.
+===
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+now
+Now
+String
+Specifies a time string that sets the absolute time used for any relative time specifier in the search. This value defaults to the current system time.
You can specify a relative time modifier for this parameter. For example, specify +2d to specify the current time plus two days. If you specify a relative time modifier both in this parameter and in the search string, the search string modifier takes precedence.
For information about relative time modifiers, see Time modifiers for search in the Search Reference.
+-
+The time string.
+===
+reduce_freq
+ReduceFrequency
+int
+Sets the time to wait between running the MapReduce phase on accumulated map values.
+-
+The time to wait, in seconds.
+===
+reload_macros
+ReloadMacros
+boolean
+Indicates whether to reload macro definitions from the macros.conf configuration file.
+-
+{@code true} to reload macro definitions, {@code false} if not.
+===
+remote_server_list
+RemoteServerList
+String[]-CSV
+Sets a list of (possibly wildcarded) servers from which to pull raw events. This same server list is used in subsearches.
+-
+The list of servers.
+===
+rf
+RequiredFieldList
+String[]-MULTIPLE
+Sets one or more required fields to the search. These fields, even if not referenced or used directly by the search, are still included by the events and summary endpoints. Splunk Web uses these fields to prepopulate panels in the Search view.
+-
+The list of fields.
+===
+rt_blocking
+RealtimeBlocking
+boolean
+Indicates whether the indexer blocks if the queue for this search is full. Only applies to real-time searches.
+-
+{@code true} to block the indexer for a full queue, {@code false} if not.
+===
+rt_indexfilter
+RealtimeIndexFilter
+boolean
+Indicates whether the indexer pre-filters events. Only applies to real-time searches.
+-
+{@code true} to pre-filter events, {@code false} if not.
+===
+rt_maxblocksecs
+RealtimeMaximumBlockSeconds
+int
+Sets the number of seconds indicating the maximum time to block. A value of 0 means no limit. For real-time searches with "rt_blocking" set to {@code true}.
+-
+The maximum time to block, in seconds.
+===
+rt_queue_size
+RealtimeQueueSize
+int
+Sets the number indicating the queue size (in events) that the indexer should use for this search. Only applies to real-time searches.
+-
+The queue size, in events.
+===
+search_listener
+SearchListener
+String
+Sets a string that registers a search state listener with the search. Use the format: {@code search_state;results_condition;http_method;uri;}
For example:
{@code search_listener=onResults;true;POST;/servicesNS/admin/search/saved/search/foobar/notify;}
+-
+The search listener string.
+===
+search_mode
+SearchMode
+SearchMode
+Sets the search mode ("normal" or "realtime").
+-
+The search mode.
+===
+spawn_process
+SpawnProcess
+boolean
+Indicates whether the search should run in a separate spawned process. Searches against indexes must run in a separate process.
+-
+{@code true} to run the search in a separate process, {@code false} if not.
+===
+status_buckets
+StatusBuckets
+int
+Sets the maximum number of status buckets to generate. A value of 0 means to not generate timeline information.
+-
+The maximum number of buckets.
+===
+sync_bundle_replication
+SynchronizeBundleReplication
+boolean
+Indicates whether this search should wait for bundle replication to complete.
+-
+{@code true} to wait for bundle replication, {@code false} if not.
+===
+# TODO: Improve docs: There is no {start,end}_time. Perhaps {earliest,latest}_time was intended?
+time_format
+TimeFormat
+String
+Sets the format for converting a formatted time string from {start,end}_time into UTC seconds. The default value is ISO-8601.
+-
+The time format string.
+===
+timeout
+Timeout
+int
+Sets the number of seconds to keep this search after processing has stopped.
+-
+The timeout, in seconds.
+===
\ No newline at end of file
diff --git a/argsGenerator/specs/JobEventsArgs__GET_search_jobs_NAME_events.argspec b/argsGenerator/specs/JobEventsArgs__GET_search_jobs_NAME_events.argspec
new file mode 100644
index 00000000..8f27af38
--- /dev/null
+++ b/argsGenerator/specs/JobEventsArgs__GET_search_jobs_NAME_events.argspec
@@ -0,0 +1,95 @@
+# NOTE: The entire contents of this specification have been copied to
+# JobExportArgs__GET_search_jobs_export.argspec, which should be
+# updated (and regenerated) to reflect changes made to this file.
+#
+count
+Count
+int
+Sets the maximum number of results to return. To return all available results, specify 0. The default value is 100.
+-
+The maximum number of results.
+===
+# TODO: Make Date version.
+earliest_time
+EarliestTime
+String
+Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The earliest time.
+===
+f
+FieldList
+String[]-MULTIPLE
+Sets a list of fields to return for the event set.
+-
+A list of fields.
+===
+# TODO: Make Date version.
+latest_time
+LatestTime
+String
+Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The latest time.
+===
+max_lines
+MaximumLines
+int
+Sets the maximum number of lines that any single event's _raw field should contain.
+-
+The maximum number of lines. For no limit, specify 0.
+===
+offset
+Offset
+int
+Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+-
+The index of the first result to return.
+===
+# TODO: Improve docs: The referenced document does not actually document the enum constants.
+output_mode
+OutputMode
+OutputMode
+Sets the format of the output.
+-
+The output format.
+===
+output_time_format
+OutputTimeFormat
+String
+Sets a UTC time format.
+-
+A UTC time format.
+===
+search
+Search
+String
+Sets the post-processing search to apply to results.
+-
+The post-processing search query.
+===
+# TODO: Improve docs: What are the valid values for this parameter?
+segmentation
+Segmentation
+String
+Sets the type of segmentation to perform on the data, including an option to perform k/v segmentation.
+-
+The segmentation type.
+===
+# TODO: Are you sure this is the default? This time format lacks time zone and millisecond resolution.
+# TODO: Improve docs: There is no {start,end}_time. Perhaps {earliest,latest}_time was intended?
+time_format
+TimeFormat
+String
+Specifies an expression to convert a formatted time string from {start,end}_time into UTC seconds. The default format is "%m/%d/%Y:%H:%M:%S".
+-
+The time format.
+===
+# TODO: Improve docs: What effect does each value have?
+truncation_mode
+TruncationMode
+TruncationMode
+Specifies how to truncate lines to achieve the value in {@link #setMaximumLines}.
+-
+The truncation mode.
+===
diff --git a/argsGenerator/specs/JobExportArgs__GET_search_jobs_export.argspec b/argsGenerator/specs/JobExportArgs__GET_search_jobs_export.argspec
new file mode 100644
index 00000000..02fe3438
--- /dev/null
+++ b/argsGenerator/specs/JobExportArgs__GET_search_jobs_export.argspec
@@ -0,0 +1,372 @@
+# This endpoint is unusual in that most of its arguments are copied straight
+# from other endpoints. In particular:
+# * POST search/jobs
+# * GET search/jobs/{search_id}/events
+# * GET search/jobs/{search_id}/results
+#
+# Sections of arguments that have been copied from other files are clearly
+# marked by comments.
+#
+# %%%%%%%%%%%%%%%%%%
+# %%% DIRECTIVES %%%
+# %%%%%%%%%%%%%%%%%%
+#
+# Some arguments are defined multiple times by different copied sections.
+# Ignore errors related to this. The first version wins.
+!SET ignore_duplicates 1
+#
+# Some arguments from included endpoints do not apply. Ignore them.
+!SUPPRESS id
+!SUPPRESS count
+!SUPPRESS f
+!SUPPRESS offset
+!SUPPRESS search
+#
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# %%% Unique to this endpoint %%%
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+index_earliest
+IndexEarliest
+String
+Specifies the earliest time in the time range to search, based on the index time. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The earliest time.
+===
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+index_latest
+IndexLatest
+String
+Specifies the latest time in the time range to search, based on the index time. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The latest time.
+===
+output_mode
+OutputMode
+OutputMode
+Sets the format of the output.
+-
+The output format.
+===
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# %%% Subset of arguments from POST search/jobs %%%
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+auto_cancel
+AutoCancel
+int
+Sets the number of seconds of inactivity after which to automatically cancel a job. A value of 0 means never auto-cancel.
+-
+The number of seconds after which to cancel a job.
+===
+auto_finalize_ec
+AutoFinalizeEventCount
+int
+Sets the number of events to process after which to auto-finalize the search. A value of 0 means no limit.
+-
+The number of events.
+===
+auto_pause
+AutoPause
+int
+Sets the number of seconds of inactivity after which to automatically pause a job. A value of 0 means never auto-pause.
+-
+The number of seconds after which to pause.
+===
+# TODO: Make Date version.
+earliest_time
+EarliestTime
+String
+Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The earliest time.
+===
+enable_lookups
+EnableLookups
+boolean
+Indicates whether to enable lookups for this search. Enabling lookups might slow searches significantly depending on the nature of the lookups.
+-
+{@code true} to enable lookups, {@code false} if not.
+===
+force_bundle_replication
+ForceBundleReplication
+boolean
+Specifies whether this search should cause (and wait depending on the value of {@code setSynchronizeBundleReplication}) bundle synchronization with all search peers.
+-
+{@code true} if this search should cause bundle synchronization, {@code false} if not.
+===
+id
+Id
+String
+Sets a search ID (SID). If unspecified, a random ID is generated.
+-
+The search ID.
+===
+# TODO: Make Date version.
+latest_time
+LatestTime
+String
+Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The latest time.
+===
+max_time
+MaximumTime
+int
+Sets the number of seconds to run this search before finalizing. Specify 0 to never finalize.
+-
+The maximum time, in seconds.
+===
+namespace
+Namespace
+String
+Specifies the application namespace in which to restrict searches.
+-
+The namespace.
+===
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+now
+Now
+String
+Specifies a time string that sets the absolute time used for any relative time specifier in the search. This value defaults to the current system time.
You can specify a relative time modifier for this parameter. For example, specify +2d to specify the current time plus two days. If you specify a relative time modifier both in this parameter and in the search string, the search string modifier takes precedence.
For information about relative time modifiers, see Time modifiers for search in the Search Reference.
+-
+A time string.
+===
+reduce_freq
+ReduceFrequency
+int
+Sets the time to wait between running the MapReduce phase on accumulated map values.
+-
+The time to wait, in seconds.
+===
+reload_macros
+ReloadMacros
+boolean
+Indicates whether to reload macro definitions from the macros.conf configuration file.
+-
+{@code true} to reload macro definitions, {@code false} if not.
+===
+remote_server_list
+RemoteServerList
+String[]-CSV
+Sets a list of (possibly wildcarded) servers from which to pull raw events. This same server list is used in subsearches.
+-
+A list of servers.
+===
+rf
+RequiredFieldList
+String[]-MULTIPLE
+Sets one or more required fields to the search. These fields, even if not referenced or used directly by the search, are still included by the events and summary endpoints. Splunk Web uses these fields to prepopulate panels in the Search view.
+-
+The list of fields.
+===
+rt_blocking
+RealtimeBlocking
+boolean
+Indicates whether the indexer blocks if the queue for this search is full. Only applies to real-time searches.
+-
+{@code true} to block the indexer for a full queue, {@code false} if not.
+===
+rt_indexfilter
+RealtimeIndexFilter
+boolean
+Indicates whether the indexer pre-filters events. Only applies to real-time searches.
+-
+{@code true} to pre-filter events, {@code false} if not.
+===
+rt_maxblocksecs
+RealtimeMaximumBlockSeconds
+int
+Sets the number of seconds indicating the maximum time to block. A value of 0 means no limit. For real-time searches with "rt_blocking" set to {@code true}.
+-
+The maximum time to block, in seconds.
+===
+rt_queue_size
+RealtimeQueueSize
+int
+Sets the number indicating the queue size (in events) that the indexer should use for this search. Only applies to real-time searches.
+-
+The queue size, in events.
+===
+search_listener
+SearchListener
+String
+Sets a string that registers a search state listener with the search. Use the format: {@code search_state;results_condition;http_method;uri;}
For example:
{@code search_listener=onResults;true;POST;/servicesNS/admin/search/saved/search/foobar/notify;}
+-
+The search listener string.
+===
+search_mode
+SearchMode
+SearchMode
+Sets the search mode ("normal" or "realtime").
+-
+The search mode.
+===
+sync_bundle_replication
+SynchronizeBundleReplication
+boolean
+Indicates whether this search should wait for bundle replication to complete.
+-
+{@code true} to wait for bundle replication, {@code false} if not.
+===
+# TODO: Improve docs: There is no {start,end}_time. Perhaps {earliest,latest}_time was intended?
+time_format
+TimeFormat
+String
+Sets the format for converting a formatted time string from {start,end}_time into UTC seconds. The default value is ISO-8601.
+-
+The time format string.
+===
+timeout
+Timeout
+int
+Sets the number of seconds to keep this search after processing has stopped.
+-
+The timeout, in seconds.
+===
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# %%% GET search/jobs/{search_id}/events %%%
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# NOTE: The entire contents of this specification have been copied to
+# JobExportArgs__GET_search_jobs_export.argspec, which should be
+# updated (and regenerated) to reflect changes made to this file.
+#
+count
+Count
+int
+Sets the maximum number of results to return. To return all available results, specify 0. The default value is 100.
+-
+The maximum number of results.
+===
+# TODO: Make Date version.
+earliest_time
+EarliestTime
+String
+Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The earliest time.
+===
+f
+FieldList
+String[]-MULTIPLE
+Sets a list of fields to return for the event set.
+-
+A list of fields.
+===
+# TODO: Make Date version.
+latest_time
+LatestTime
+String
+Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The latest time.
+===
+max_lines
+MaximumLines
+int
+Sets the maximum number of lines that any single event's _raw field should contain.
+-
+The maximum number of lines. For no limit, specify 0.
+===
+offset
+Offset
+int
+Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+-
+The index of the first result to return.
+===
+# TODO: Improve docs: The referenced document does not actually document the enum constants.
+output_mode
+OutputMode
+OutputMode
+Sets the format of the output.
+-
+The output format.
+===
+output_time_format
+OutputTimeFormat
+String
+Sets a UTC time format.
+-
+A UTC time format.
+===
+search
+Search
+String
+Sets the post-processing search to apply to results.
+-
+The post-processing search query.
+===
+# TODO: Improve docs: What are the valid values for this parameter?
+segmentation
+Segmentation
+String
+Sets the type of segmentation to perform on the data, including an option to perform k/v segmentation.
+-
+The segmentation type.
+===
+# TODO: Are you sure this is the default? This time format lacks time zone and millisecond resolution.
+# TODO: Improve docs: There is no {start,end}_time. Perhaps {earliest,latest}_time was intended?
+time_format
+TimeFormat
+String
+Specifies an expression to convert a formatted time string from {start,end}_time into UTC seconds. The default format is "%m/%d/%Y:%H:%M:%S".
+-
+The time format.
+===
+# TODO: Improve docs: What effect does each value have?
+truncation_mode
+TruncationMode
+TruncationMode
+Specifies how to truncate lines to achieve the value in {@link #setMaximumLines}.
+-
+The truncation mode.
+===
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# %%% GET search/jobs/{search_id}/results %%%
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# NOTE: The entire contents of this specification have been copied to
+# JobExportArgs__GET_search_jobs_export.argspec, which should be
+# updated (and regenerated) to reflect changes made to this file.
+#
+# TODO: Improve docs: Formatting of the description differs from that of
+# GET search/jobs/{search_id}/results. Otherwise all other parameters are identical.
+count
+Count
+int
+Sets the maximum number of results to return.
+-
+The maximum number of results. To return all available results, specify 0.
+===
+# TODO: Improve docs: Why isn't "field_list" deprecated when there is "f" present?
+f
+FieldList
+String[]-MULTIPLE
+Sets a list of fields to return for the event set.
+-
+A list of fields.
+===
+offset
+Offset
+int
+Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+-
+The index of the first result to return.
+===
+# TODO: Improve docs: The referenced document does not actually document the enum constants.
+output_mode
+OutputMode
+OutputMode
+Sets the format of the output.
+-
+The output format.
+===
+search
+Search
+String
+Sets the post-processing search to apply to results.
+-
+The post-processing search query.
+===
diff --git a/argsGenerator/specs/JobResultsArgs__GET_search_jobs_NAME_results.argspec b/argsGenerator/specs/JobResultsArgs__GET_search_jobs_NAME_results.argspec
new file mode 100644
index 00000000..5a13dfd5
--- /dev/null
+++ b/argsGenerator/specs/JobResultsArgs__GET_search_jobs_NAME_results.argspec
@@ -0,0 +1,43 @@
+# NOTE: The entire contents of this specification have been copied to
+# JobExportArgs__GET_search_jobs_export.argspec, which should be
+# updated (and regenerated) to reflect changes made to this file.
+#
+# TODO: Improve docs: Formatting of the description differs from that of
+# GET search/jobs/{search_id}/results. Otherwise all other parameters are identical.
+count
+Count
+int
+Sets the maximum number of results to return.
+-
+The maximum number of results. To return all available results, specify 0.
+===
+# TODO: Improve docs: Why isn't "field_list" deprecated when there is "f" present?
+f
+FieldList
+String[]-MULTIPLE
+Sets a list of fields to return for the event set.
+-
+A list of fields.
+===
+offset
+Offset
+int
+Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+-
+The index of the first result to return.
+===
+# TODO: Improve docs: The referenced document does not actually document the enum constants.
+output_mode
+OutputMode
+OutputMode
+Sets the format of the output.
+-
+The output format.
+===
+search
+Search
+String
+Sets the post-processing search to apply to results.
+-
+The post-processing search query.
+===
diff --git a/argsGenerator/specs/JobResultsPreviewArgs__GET_search_jobs_NAME_results_preview.argspec b/argsGenerator/specs/JobResultsPreviewArgs__GET_search_jobs_NAME_results_preview.argspec
new file mode 100644
index 00000000..a37eb28a
--- /dev/null
+++ b/argsGenerator/specs/JobResultsPreviewArgs__GET_search_jobs_NAME_results_preview.argspec
@@ -0,0 +1,39 @@
+# TODO: Improve docs: Formatting of the description differs from that of
+# GET search/jobs/{search_id}/results_preview. Otherwise all other parameters are identical.
+count
+Count
+int
+Sets the maximum number of results to return.
+-
+The maximum number of results. To return all available results, specify 0.
+===
+# TODO: Improve docs: Why isn't "field_list" deprecated when there is "f" present?
+f
+FieldList
+String[]-MULTIPLE
+Sets a list of fields to return for the event set.
+-
+A list of fields.
+===
+offset
+Offset
+int
+Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+-
+The index of the first result to return.
+===
+# TODO: Improve docs: The referenced document does not actually document the enum constants.
+output_mode
+OutputMode
+OutputMode
+Sets the format of the output.
+-
+The output format.
+===
+search
+Search
+String
+Sets the post-processing search to apply to results.
+-
+The post-processing search query.
+===
diff --git a/argsGenerator/specs/JobSummaryArgs__GET_search_jobs_NAME_summary.argspec b/argsGenerator/specs/JobSummaryArgs__GET_search_jobs_NAME_summary.argspec
new file mode 100644
index 00000000..ee99882a
--- /dev/null
+++ b/argsGenerator/specs/JobSummaryArgs__GET_search_jobs_NAME_summary.argspec
@@ -0,0 +1,72 @@
+# TODO: Make Date version.
+# TODO: Improve docs: "respectively"?
+earliest_time
+EarliestTime
+String
+Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The earliest time.
+===
+f
+FieldList
+String[]-MULTIPLE
+Sets a list of fields to return for the event set.
+-
+A list of fields.
+===
+histogram
+Histogram
+boolean
+Indicates whether to add histogram data to the summary output.
+-
+{@code true} to add histogram data, {@code false} if not.
+===
+# TODO: Make Date version.
+# TODO: Improve docs: "respectively"?
+latest_time
+LatestTime
+String
+Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+-
+The latest time.
+===
+min_freq
+MinimumFrequency
+double
+Sets the fraction of results for each key that this key must occur in to be displayed.
+-
+The frequency, as a fraction (a value between 0 and 1).
+===
+# TODO: Improve docs: The description and default value contradict each other.
+output_time_format
+OutputTimeFormat
+String
+Sets a UTC time format.
+-
+A UTC time format.
+===
+search
+Search
+String
+Sets a search query to filter the response. The response matches field values against the search query. For example, "foo" matches any object that has "foo" as a substring in a field, and "field_name=field_value" restricts the match to a single field.
+-
+A search substring.
+===
+# TODO: Improve docs: The default value specified does not match that of the description.
+# (It is missing a trailing S). The description version is probably right.
+# TODO: Improve docs: Are you sure this is the default? This time format lacks time zone and millisecond resolution.
+# TODO: Improve docs: There is no {start,end}_time. Perhaps {earliest,latest}_time was intended?
+time_format
+TimeFormat
+String
+Specifies an expression to convert a formatted time string from {start,end}_time into UTC seconds. The default format is "%m/%d/%Y:%H:%M:%S".
+-
+The time format.
+===
+top_count
+TopCount
+int
+Sets for each key how many of the most frequent items to return.
+-
+The number of items to return.
+===
diff --git a/argsGenerator/specs/SavedSearchCollectionArgs__GET_saved_searches.argspec b/argsGenerator/specs/SavedSearchCollectionArgs__GET_saved_searches.argspec
new file mode 100644
index 00000000..489f6485
--- /dev/null
+++ b/argsGenerator/specs/SavedSearchCollectionArgs__GET_saved_searches.argspec
@@ -0,0 +1,18 @@
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+earliest_time
+EarliestTime
+String
+Sets the earliest time for which to display the scheduled times for scheduled searches (not just the next run time).
+-
+The earliest time.
+===
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+latest_time
+LatestTime
+String
+Sets the latest time until which to display the scheduled times for scheduled searches (not just the next run time).
+-
+The latest time.
+===
diff --git a/argsGenerator/specs/SavedSearchDispatchArgs__POST_saved_searches_NAME_dispatch.argspec b/argsGenerator/specs/SavedSearchDispatchArgs__POST_saved_searches_NAME_dispatch.argspec
new file mode 100644
index 00000000..f4056f22
--- /dev/null
+++ b/argsGenerator/specs/SavedSearchDispatchArgs__POST_saved_searches_NAME_dispatch.argspec
@@ -0,0 +1,129 @@
+# TODO: Improve docs: What is the accepted time format?
+# TODO: Make Date version.
+dispatch.now
+DispatchNow
+String
+Sets a time that dispatches the search as though the specified time were the current time.
+-
+A string with the specified time.
+===
+dispatch.buckets
+DispatchBuckets
+int
+Sets the maximum number of timeline buckets.
+-
+The maximum number of timeline buckets.
+===
+dispatch.earliest_time
+DispatchEarliestTime
+String
+Specifies the earliest time for this search. This value can be a relative or absolute time. If this value is an absolute time, use {@link #setDispatchTimeFormat} to format the value.
+-
+A time string that specifies the earliest time for this search.
+===
+dispatch.earliest_time
+DispatchEarliestTime
+Date
+Sets the earliest time for this search.
+-
+A date that specifies the earliest time for this search.
+!CODE
+ // Documented format: "%FT%T.%Q%:z"
+ // strftime original format: "%FT%T.%Q%:z"
+ // strftime expanded format: "%Y-%m-%dT%H:%M:%S.%Q%:z"
+ String javaFormatString = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ String timeString = new SimpleDateFormat(javaFormatString).format(dispatchEarliestTime);
+ this.put("dispatch.earliest_time", timeString);
+===
+dispatch.latest_time
+DispatchLatestTime
+String
+Specifies the latest time for this search. This value can be a relative or absolute time. If this value is an absolute time, use {@link #setDispatchTimeFormat} to format the value.
+-
+A time string that specifies the latest time for this search.
+===
+dispatch.latest_time
+DispatchLatestTime
+Date
+Sets the latest time for this search.
+-
+A date that specifies the latest time for this saved search.
+!CODE
+ // Documented format: "%FT%T.%Q%:z"
+ // strftime original format: "%FT%T.%Q%:z"
+ // strftime expanded format: "%Y-%m-%dT%H:%M:%S.%Q%:z"
+ String javaFormatString = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ String timeString = new SimpleDateFormat(javaFormatString).format(dispatchLatestTime);
+ this.put("dispatch.latest_time", timeString);
+===
+dispatch.lookups
+DispatchLookups
+boolean
+Indicates whether to enable lookups for this search.
+-
+{@code true} to enable lookups, {@code false} if not.
+===
+dispatch.max_count
+DispatchMaximumCount
+int
+Sets the maximum number of results before finalizing the search.
+-
+The maximum number of results.
+===
+dispatch.max_time
+DispatchMaximumTime
+int
+Sets the the maximum amount of time before finalizing the search.
+-
+The maximum amount of time, in seconds.
+===
+dispatch.reduce_freq
+DispatchReduceFrequency
+int
+Set the frequency for how often Splunk should run the MapReduce reduce phase on accumulated map values.
+-
+The frequency, in seconds.
+===
+dispatch.rt_backfill
+DispatchRealTimeBackfill
+boolean
+Indicates whether to back fill the real-time window for this search. This value only applies to real-time searches.
+-
+{@code true} to back fill the real-time window, {@code false} if not.
+===
+dispatch.spawn_process
+DispatchSpawnProcess
+boolean
+Indicates whether the search should run in a separate spawned process. Searches against indexes must run in a separate process.
+-
+{@code true} to run the search in a separate process, {@code false} if not.
+===
+dispatch.time_format
+DispatchTimeFormat
+String
+Sets a time format for Splunk to use to specify the earliest and latest times.
+-
+A time format string.
+===
+dispatch.ttl
+# The TTL acronym is not expanded here to be consistent with Job.getTtl
+DispatchTtl
+String
+Indicates the time to live (TTL) for the artifacts of the scheduled search, if no actions are triggered. If an action is triggered, Splunk changes the TTL to that action's TTL. If multiple actions are triggered, Splunk applies the maximum TTL to the artifacts. To set the action's TTL, refer to alert_actions.conf.spec.
+-
+The time to live, in seconds. If the value is a number followed by "p", it is the number of scheduled search periods.
+===
+trigger_actions
+TriggerActions
+boolean
+Indicates whether to trigger alert actions.
+-
+{@code true} to trigger alert actions, {@code false} if not.
+===
+force_dispatch
+ForceDispatch
+boolean
+Indicates whether to start a new search, even if another instance of this search is already running.
+-
+{@code true} to start a new search, {@code false} if not.
+===
diff --git a/build.properties b/build.properties
deleted file mode 100644
index 457f19c1..00000000
--- a/build.properties
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2011 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.
-
-version.number=0.1.0
-
-dir.build=build
-dir.build.examples=${dir.build}/examples
-dir.build.splunk=${dir.build}/splunk
-dir.build.splunk-sdk=${dir.build}/splunk-sdk
-dir.build.tests=${dir.build}/tests
-dir.dist=dist
-dir.dist.docs=${dir.dist}/docs
-dir.dist.examples=${dir.dist}/examples
-dir.examples=examples
-dir.lib=lib
-dir.splunk=splunk
-dir.splunk-sdk=splunk-sdk
-dir.tests=tests
-
-lib.commons-cli=${dir.lib}/commons-cli-1.2.jar
-lib.junit=${dir.lib}/junit-4.8.1.jar
-lib.org-openide-explorer=${dir.lib}/org-openide-explorer.jar
-lib.org-openide-nodes=${dir.lib}/org-openide-nodes.jar
-lib.org-openide-util=${dir.lib}/org-openide-util.jar
-lib.org-openide-util-lookup=${dir.lib}/org-openide-util-lookup.jar
-
-dist.splunk=${dir.dist}/splunk.jar
-dist.splunk-sdk=${dir.dist}/splunk-sdk.jar
-dist.tests=${dir.dist}/tests.jar
diff --git a/build.xml b/build.xml
deleted file mode 100644
index b19ce9ea..00000000
--- a/build.xml
+++ /dev/null
@@ -1,308 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/deploy b/deploy
new file mode 100755
index 00000000..ab8acd24
--- /dev/null
+++ b/deploy
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+declare -r scriptDirectory="$(dirname $(readlink -e $0))"
+declare -r scriptName="$(basename $0)"
+declare -r version="1.9.5"
+
+if [[ $# -ne 1 ]]; then
+ echo 1>&2 "Usage: ${scriptName} {local|staging||production}"
+fi
+
+case $1 in
+local)
+ declare -r url="file:///${HOME}/.m2/repository/"
+ declare -r repositoryId=""
+ ;;
+staging)
+ declare -r url="http://stg-artifactory:8081/artifactory/devplat-staging/"
+ declare -r repositoryId="splunk-staging-artifactory"
+ ;;
+production)
+ declare -r url="https://splunk.artifactoryonline.com/splunk/ext-releases-local/"
+ declare -r repositoryId="splunk-production-artifactory"
+ ;;
+esac
+
+cd "${scriptDirectory}"
+
+mvn deploy:deploy-file -Ddescription="The Splunk SDK for Java" -Dfile=dist/splunk-${version}.jar \
+ -DgroupId=com.splunk -DartifactId=splunk -Dversion=${version}.0 -Dpackaging=jar \
+ -Djavadoc=dist/splunk-${version}-javadoc.jar \
+ -Dsources=dist/splunk-${version}-sources.jar \
+ -DrepositoryId="${repositoryId}" \
+ -DupdateReleaseInfo=true \
+ -Durl="${url}"
diff --git a/deploy.md b/deploy.md
new file mode 100644
index 00000000..aed545f5
--- /dev/null
+++ b/deploy.md
@@ -0,0 +1,38 @@
+##NAME
+
+deploy - Transmit splunk-sdk-java artifacts to the local, staging or production
+maven artifact repository
+
+##SYNOPSIS
+
+deploy \
+
+##DESCRIPTION
+
+Deploy transmits **target/splunk-1.9.5.jar**, **target/splunk-1.9.5-javadoc.jar**, and
+**target/splunk-1.9.5-sources.jar** to the **local**, **staging**, or **production**
+maven repository. Repository names are mapped to locations as follows.
+
+| repository-name | location |
+|-----------------|----------------------------------------------------------------|
+| local | file:///${HOME}/.m2/repository/ |
+| staging | http://stg-artifactory:8081/artifactory/devplat-staging/ | |
+| production | https://splunk.jfrog.io/artifactory/ext-releases-local/ |
+
+After deployment you should find this tree structure at the location of your repository
+
+ com/splunk/splunk/1.9.5/
+ ├── splunk-1.9.5-javadoc.jar
+ ├── splunk-1.9.5-javadoc.jar.md5
+ ├── splunk-1.9.5-javadoc.jar.sha1
+ ├── splunk-1.9.5-sources.jar
+ ├── splunk-1.9.5-sources.jar.md5
+ ├── splunk-1.9.5-sources.jar.sha1
+ ├── splunk-1.9.5.jar
+ ├── splunk-1.9.5.jar.md5
+ ├── splunk-1.9.5.jar.sha1
+ ├── splunk-1.9.5.pom
+ ├── splunk-1.9.5.pom.md5
+ └── splunk-1.9.5.pom.sha1
+
+Verify this structure prior to release.
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..4584c6d3
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,23 @@
+version: '3.6'
+
+services:
+ splunk:
+ image: "splunk/splunk:latest"
+ container_name: splunk
+ environment:
+ - SPLUNK_START_ARGS=--accept-license
+ - SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
+ - SPLUNK_PASSWORD=changed!
+ - SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.1.0/sdkappcollection.tgz
+ - JAVA_VERSION=openjdk:8
+ ports:
+ - 8000:8000
+ - 8088:8088
+ - 8089:8089
+ - 10667:10667
+ - 10668:10668/udp
+ healthcheck:
+ test: ['CMD', 'curl', '-f', 'http://localhost:8000']
+ interval: 5s
+ timeout: 5s
+ retries: 20
diff --git a/examples/explorer/explorer.iml b/examples/examples.iml
similarity index 68%
rename from examples/explorer/explorer.iml
rename to examples/examples.iml
index f878340c..a8093d19 100644
--- a/examples/explorer/explorer.iml
+++ b/examples/examples.iml
@@ -8,8 +8,11 @@
-
+
+
+
+
diff --git a/examples/export/export.iml b/examples/export/export.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/export/export.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/index/index.iml b/examples/index/index.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/index/index.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/pom.xml b/examples/pom.xml
new file mode 100644
index 00000000..18bbb711
--- /dev/null
+++ b/examples/pom.xml
@@ -0,0 +1,120 @@
+
+
+ 4.0.0
+
+ examples
+
+ splunk-sdk-java
+ com.splunk
+ 1.0.1
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M5
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ 3.0.0-M1
+
+ true
+
+
+
+
+
+
+
+ com.splunk
+ splunk
+ 1.9.5
+ provided
+
+
+ org.netbeans.api
+ org-openide-util-lookup
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-util
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-filesystems
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-awt
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-dialogs
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-nodes
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-explorer
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-execution
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-modules
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-windows
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-text
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-options
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-loaders
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-io
+ RELEASE124
+
+
+ org.netbeans.api
+ org-openide-actions
+ RELEASE124
+
+
+
+
diff --git a/examples/search_blocking/search_blocking.iml b/examples/search_blocking/search_blocking.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/search_blocking/search_blocking.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/search_oneshot/search_oneshot.iml b/examples/search_oneshot/search_oneshot.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/search_oneshot/search_oneshot.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/search_realtime/search_realtime.iml b/examples/search_realtime/search_realtime.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/search_realtime/search_realtime.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/spurl/spurl.iml b/examples/spurl/spurl.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/spurl/spurl.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/src/main/java/com/splunk/examples/endpoint_instantiation/Program.java b/examples/src/main/java/com/splunk/examples/endpoint_instantiation/Program.java
new file mode 100644
index 00000000..8cb24f5e
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/endpoint_instantiation/Program.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2015 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.examples.endpoint_instantiation;
+
+import com.splunk.*;
+
+/**
+ * This example shows how to access any Splunk REST API endpoint.
+ * Here, we are just getting an EntityCollection of Entity objects representing
+ * apps on the Splunk server.
+ *
+ * You can also write a class which inherits from the Entity class.
+ * A minimal example of this is:
+ *
+ * public class MyEntity extends Entity {
+ * MyEntity(Service service, String path) {
+ * super(service, path);
+ * }
+ * }
+ *
+ * Then, you can write a class which inherits from the EntityCollection class.
+ * A minimal example of this is:
+ *
+ * public class MyEntityCollection extends EntityCollection {
+ * MyEntityCollection(Service service) {
+ * super(service, "path/hardcoded", MyEntity.class, new Args());
+ * }
+ * }
+ */
+
+public class Program {
+ public static void main(String[] args) {
+ Command command = Command.splunk("info").parse(args);
+ Service service = Service.connect(command.opts);
+
+ String mySplunkRESTPath = "apps/local";
+
+ EntityCollection myCollection = new EntityCollection(service, mySplunkRESTPath, Entity.class, new Args());
+
+ System.out.println("Found " + myCollection.size() + " Splunk apps:");
+
+ for (Object myEntity : myCollection.values()) {
+ Entity entity = (Entity) myEntity;
+ System.out.println("\t" + entity.getName());
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/explorer/com/splunk/sdk/explorer/AppNode.java b/examples/src/main/java/com/splunk/examples/explorer/AppNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/AppNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/AppNode.java
index 87d886de..50caaffc 100644
--- a/examples/explorer/com/splunk/sdk/explorer/AppNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/AppNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Application;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/ConfCollectionKids.java b/examples/src/main/java/com/splunk/examples/explorer/ConfCollectionKids.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/ConfCollectionKids.java
rename to examples/src/main/java/com/splunk/examples/explorer/ConfCollectionKids.java
index 6a406bd8..c7549f47 100644
--- a/examples/explorer/com/splunk/sdk/explorer/ConfCollectionKids.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/ConfCollectionKids.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.ConfCollection;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/ConfCollectionNode.java b/examples/src/main/java/com/splunk/examples/explorer/ConfCollectionNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/ConfCollectionNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/ConfCollectionNode.java
index c8b0172d..1f1b9e44 100644
--- a/examples/explorer/com/splunk/sdk/explorer/ConfCollectionNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/ConfCollectionNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.ConfCollection;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DatePropertyEditor.java b/examples/src/main/java/com/splunk/examples/explorer/DatePropertyEditor.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/DatePropertyEditor.java
rename to examples/src/main/java/com/splunk/examples/explorer/DatePropertyEditor.java
index 118db164..d73dbaca 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DatePropertyEditor.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DatePropertyEditor.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import java.beans.PropertyEditorSupport;
import java.text.ParseException;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DeploymentClientNode.java b/examples/src/main/java/com/splunk/examples/explorer/DeploymentClientNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/DeploymentClientNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/DeploymentClientNode.java
index 5b39f117..b0255ecd 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DeploymentClientNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DeploymentClientNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DeploymentServerClassNode.java b/examples/src/main/java/com/splunk/examples/explorer/DeploymentServerClassNode.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/DeploymentServerClassNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/DeploymentServerClassNode.java
index ea402e4f..8c5733df 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DeploymentServerClassNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DeploymentServerClassNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DeploymentServerNode.java b/examples/src/main/java/com/splunk/examples/explorer/DeploymentServerNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/DeploymentServerNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/DeploymentServerNode.java
index e5aff20e..79e33e78 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DeploymentServerNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DeploymentServerNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DeploymentTenantNode.java b/examples/src/main/java/com/splunk/examples/explorer/DeploymentTenantNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/DeploymentTenantNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/DeploymentTenantNode.java
index 338c2401..48c14259 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DeploymentTenantNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DeploymentTenantNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DistributedConfigurationNode.java b/examples/src/main/java/com/splunk/examples/explorer/DistributedConfigurationNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/DistributedConfigurationNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/DistributedConfigurationNode.java
index 5ad76aa4..73c2cec8 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DistributedConfigurationNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DistributedConfigurationNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/DistributedPeerNode.java b/examples/src/main/java/com/splunk/examples/explorer/DistributedPeerNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/DistributedPeerNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/DistributedPeerNode.java
index af1c6dbf..9139d601 100644
--- a/examples/explorer/com/splunk/sdk/explorer/DistributedPeerNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/DistributedPeerNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/EntityCollectionNode.java b/examples/src/main/java/com/splunk/examples/explorer/EntityCollectionNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/EntityCollectionNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/EntityCollectionNode.java
index e8c251ba..92819273 100644
--- a/examples/explorer/com/splunk/sdk/explorer/EntityCollectionNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/EntityCollectionNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
import com.splunk.EntityCollection;
@@ -49,7 +49,7 @@ Node createKid(Entity entity) {
return (Node)itemCtor.newInstance(entity);
}
catch (Exception e) {
- throw new RuntimeException(e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
}
}
diff --git a/examples/explorer/com/splunk/sdk/explorer/EntityComparator.java b/examples/src/main/java/com/splunk/examples/explorer/EntityComparator.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/EntityComparator.java
rename to examples/src/main/java/com/splunk/examples/explorer/EntityComparator.java
index ff0ab7c7..8547fa9f 100644
--- a/examples/explorer/com/splunk/sdk/explorer/EntityComparator.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/EntityComparator.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/EntityKids.java b/examples/src/main/java/com/splunk/examples/explorer/EntityKids.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/EntityKids.java
rename to examples/src/main/java/com/splunk/examples/explorer/EntityKids.java
index fe8d2db6..a1776980 100644
--- a/examples/explorer/com/splunk/sdk/explorer/EntityKids.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/EntityKids.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
import com.splunk.EntityMetadata;
diff --git a/examples/explorer/com/splunk/sdk/explorer/EntityMetadataNode.java b/examples/src/main/java/com/splunk/examples/explorer/EntityMetadataNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/EntityMetadataNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/EntityMetadataNode.java
index 28340187..9e07beb2 100644
--- a/examples/explorer/com/splunk/sdk/explorer/EntityMetadataNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/EntityMetadataNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.EntityMetadata;
diff --git a/examples/explorer/com/splunk/sdk/explorer/EntityNode.java b/examples/src/main/java/com/splunk/examples/explorer/EntityNode.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/EntityNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/EntityNode.java
index ec7e2dfc..1d6262d9 100644
--- a/examples/explorer/com/splunk/sdk/explorer/EntityNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/EntityNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/EventTypeNode.java b/examples/src/main/java/com/splunk/examples/explorer/EventTypeNode.java
similarity index 91%
rename from examples/explorer/com/splunk/sdk/explorer/EventTypeNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/EventTypeNode.java
index 840ef833..943b179c 100644
--- a/examples/explorer/com/splunk/sdk/explorer/EventTypeNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/EventTypeNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
@@ -25,7 +25,7 @@ class EventTypeNode extends EntityNode {
@Override protected PropertyList getMetadata() {
PropertyList list = super.getMetadata();
- list.add(String.class, "getDescription");
+ list.add(String.class, "getDescriptionLabel");
list.add(int.class, "getPriority");
list.add(String.class, "getSearch");
return list;
diff --git a/examples/explorer/com/splunk/sdk/explorer/Explorer.java b/examples/src/main/java/com/splunk/examples/explorer/Explorer.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/Explorer.java
rename to examples/src/main/java/com/splunk/examples/explorer/Explorer.java
index e249bc7d..82a4ccef 100644
--- a/examples/explorer/com/splunk/sdk/explorer/Explorer.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/Explorer.java
@@ -20,7 +20,7 @@
// http://blogs.oracle.com/geertjan/entry/netbeans_apis_outside_of_the
//
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.InputKind;
import com.splunk.Service;
diff --git a/examples/explorer/com/splunk/sdk/explorer/ExplorerNode.java b/examples/src/main/java/com/splunk/examples/explorer/ExplorerNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/ExplorerNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/ExplorerNode.java
index ca3c76c9..27478991 100644
--- a/examples/explorer/com/splunk/sdk/explorer/ExplorerNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/ExplorerNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
diff --git a/examples/explorer/com/splunk/sdk/explorer/GroupNode.java b/examples/src/main/java/com/splunk/examples/explorer/GroupNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/GroupNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/GroupNode.java
index fd38c510..bd143ea2 100644
--- a/examples/explorer/com/splunk/sdk/explorer/GroupNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/GroupNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
diff --git a/examples/explorer/com/splunk/sdk/explorer/IndexNode.java b/examples/src/main/java/com/splunk/examples/explorer/IndexNode.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/IndexNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/IndexNode.java
index 156aa084..b9a73a2a 100644
--- a/examples/explorer/com/splunk/sdk/explorer/IndexNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/IndexNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/InputKindPropertyEditor.java b/examples/src/main/java/com/splunk/examples/explorer/InputKindPropertyEditor.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/InputKindPropertyEditor.java
rename to examples/src/main/java/com/splunk/examples/explorer/InputKindPropertyEditor.java
index 43bc6905..599cf351 100644
--- a/examples/explorer/com/splunk/sdk/explorer/InputKindPropertyEditor.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/InputKindPropertyEditor.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.InputKind;
diff --git a/examples/explorer/com/splunk/sdk/explorer/InputNode.java b/examples/src/main/java/com/splunk/examples/explorer/InputNode.java
similarity index 84%
rename from examples/explorer/com/splunk/sdk/explorer/InputNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/InputNode.java
index e5be924c..d440e815 100644
--- a/examples/explorer/com/splunk/sdk/explorer/InputNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/InputNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
import com.splunk.Input;
@@ -29,60 +29,51 @@ class InputNode extends EntityNode {
PropertyList list = super.getMetadata();
list.add(InputKind.class, "getKind");
Input input = (Input)value;
- switch (input.getKind()) {
- case Monitor:
+ InputKind kind = input.getKind();
+ if (kind == InputKind.Monitor) {
list.add(int.class, "getFileCount");
list.add(String.class, "getHost");
list.add(String.class, "getIndex");
list.add(int.class, "getRcvBuf");
- break;
- case Script:
+ } else if (kind == InputKind.Script) {
list.add(String.class, "getGroup");
list.add(String.class, "getHost");
list.add(String.class, "getIndex");
list.add(int.class, "getInterval");
list.add(int.class, "getRcvBuf");
- break;
- case Tcp:
+ } else if (kind == InputKind.Tcp) {
list.add(String.class, "getGroup");
list.add(String.class, "getHost");
list.add(String.class, "getIndex");
list.add(int.class, "getRcvBuf");
list.add(String.class, "getRestrictToHost");
- break;
- case TcpSplunk:
- case Udp:
+ } else if (kind == InputKind.TcpSplunk || kind == InputKind.Udp) {
list.add(String.class, "getGroup");
list.add(String.class, "getHost");
list.add(String.class, "getIndex");
list.add(int.class, "getRcvBuf");
- break;
- case WindowsActiveDirectory:
+ } else if (kind == InputKind.WindowsActiveDirectory) {
list.add(String.class, "getIndex");
list.add(boolean.class, "getMonitorSubtree");
- break;
- case WindowsEventLog:
+ } else if (kind == InputKind.WindowsEventLog) {
list.add(String.class, "getHosts");
list.add(String.class, "getIndex");
list.add(String[].class, "getLogs");
list.add(String.class, "getLocalName");
list.add(String.class, "getLookupHost");
- break;
- case WindowsPerfmon:
+ } else if (kind == InputKind.WindowsPerfmon) {
list.add(String.class, "getIndex");
list.add(String[].class, "getInstances");
list.add(int.class, "getInterval");
list.add(String.class, "getObject");
- break;
- case WindowsRegistry:
+ } else if (kind == InputKind.WindowsRegistry) {
list.add(boolean.class, "getBaseline");
list.add(String.class, "getProc");
list.add(String.class, "getHive");
list.add(String.class, "getIndex");
list.add(boolean.class, "getMonitorSubnoes");
list.add(String.class, "getType");
- break;
- case WindowsWmi:
+ } else if (kind == InputKind.WindowsWmi) {
list.add(String.class, "getClasses");
list.add(String[].class, "getFields");
list.add(String.class, "getIndex");
@@ -92,7 +83,6 @@ class InputNode extends EntityNode {
list.add(String.class, "getLocalName");
list.add(String.class, "getServer");
list.add(String.class, "getWq1");
- break;
}
return list;
}
diff --git a/examples/explorer/com/splunk/sdk/explorer/JobNode.java b/examples/src/main/java/com/splunk/examples/explorer/JobNode.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/JobNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/JobNode.java
index 1ec732fe..0e56742a 100644
--- a/examples/explorer/com/splunk/sdk/explorer/JobNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/JobNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
import com.splunk.Job;
diff --git a/examples/explorer/com/splunk/sdk/explorer/LicenseGroupNode.java b/examples/src/main/java/com/splunk/examples/explorer/LicenseGroupNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/LicenseGroupNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/LicenseGroupNode.java
index 65f77d1b..06421e98 100644
--- a/examples/explorer/com/splunk/sdk/explorer/LicenseGroupNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/LicenseGroupNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/LicenseNode.java b/examples/src/main/java/com/splunk/examples/explorer/LicenseNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/LicenseNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/LicenseNode.java
index 54668b95..aadf356c 100644
--- a/examples/explorer/com/splunk/sdk/explorer/LicenseNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/LicenseNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
import com.splunk.License;
diff --git a/examples/explorer/com/splunk/sdk/explorer/LicensePoolNode.java b/examples/src/main/java/com/splunk/examples/explorer/LicensePoolNode.java
similarity index 92%
rename from examples/explorer/com/splunk/sdk/explorer/LicensePoolNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/LicensePoolNode.java
index 644cfb9b..1849d269 100644
--- a/examples/explorer/com/splunk/sdk/explorer/LicensePoolNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/LicensePoolNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
@@ -25,7 +25,7 @@ class LicensePoolNode extends EntityNode {
@Override protected PropertyList getMetadata() {
PropertyList list = super.getMetadata();
- list.add(String.class, "getDescription");
+ list.add(String.class, "getDescriptionLabel");
list.add(long.class, "getQuota");
list.add(String[].class, "getSlaves");
list.add(long.class, "getSlavesUsageBytes");
diff --git a/examples/explorer/com/splunk/sdk/explorer/LicenseSlaveNode.java b/examples/src/main/java/com/splunk/examples/explorer/LicenseSlaveNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/LicenseSlaveNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/LicenseSlaveNode.java
index 407ceae4..3340b2c7 100644
--- a/examples/explorer/com/splunk/sdk/explorer/LicenseSlaveNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/LicenseSlaveNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/LicenseStackNode.java b/examples/src/main/java/com/splunk/examples/explorer/LicenseStackNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/LicenseStackNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/LicenseStackNode.java
index 3db592d5..743b84dd 100644
--- a/examples/explorer/com/splunk/sdk/explorer/LicenseStackNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/LicenseStackNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/LoggerNode.java b/examples/src/main/java/com/splunk/examples/explorer/LoggerNode.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/LoggerNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/LoggerNode.java
index bac41e0f..4c563ddd 100644
--- a/examples/explorer/com/splunk/sdk/explorer/LoggerNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/LoggerNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/MapPropertyEditor.java b/examples/src/main/java/com/splunk/examples/explorer/MapPropertyEditor.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/MapPropertyEditor.java
rename to examples/src/main/java/com/splunk/examples/explorer/MapPropertyEditor.java
index a2a5d7b9..30f81036 100644
--- a/examples/explorer/com/splunk/sdk/explorer/MapPropertyEditor.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/MapPropertyEditor.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import java.beans.PropertyEditorSupport;
import java.util.Map;
diff --git a/examples/explorer/com/splunk/sdk/explorer/MessageNode.java b/examples/src/main/java/com/splunk/examples/explorer/MessageNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/MessageNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/MessageNode.java
index 5555a05a..be756267 100644
--- a/examples/explorer/com/splunk/sdk/explorer/MessageNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/MessageNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/NamespaceKids.java b/examples/src/main/java/com/splunk/examples/explorer/NamespaceKids.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/NamespaceKids.java
rename to examples/src/main/java/com/splunk/examples/explorer/NamespaceKids.java
index 21122ef6..f9c76609 100644
--- a/examples/explorer/com/splunk/sdk/explorer/NamespaceKids.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/NamespaceKids.java
@@ -14,11 +14,10 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Service;
-import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
diff --git a/examples/explorer/com/splunk/sdk/explorer/NamespacesKids.java b/examples/src/main/java/com/splunk/examples/explorer/NamespacesKids.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/NamespacesKids.java
rename to examples/src/main/java/com/splunk/examples/explorer/NamespacesKids.java
index ad34ca9e..5fba807d 100644
--- a/examples/explorer/com/splunk/sdk/explorer/NamespacesKids.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/NamespacesKids.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Args;
import com.splunk.Service;
@@ -47,8 +47,6 @@ class NamespacesKids extends Children.Keys {
}
private Node createNode(String name) {
- String app;
- String owner;
if (name.equals(""))
return createNode("", "-");
diff --git a/examples/explorer/com/splunk/sdk/explorer/NamespacesNode.java b/examples/src/main/java/com/splunk/examples/explorer/NamespacesNode.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/NamespacesNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/NamespacesNode.java
index 0507de2d..5a240f7a 100644
--- a/examples/explorer/com/splunk/sdk/explorer/NamespacesNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/NamespacesNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Service;
diff --git a/examples/explorer/com/splunk/sdk/explorer/OutputDefaultNode.java b/examples/src/main/java/com/splunk/examples/explorer/OutputDefaultNode.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/OutputDefaultNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/OutputDefaultNode.java
index e517969c..8cd65130 100644
--- a/examples/explorer/com/splunk/sdk/explorer/OutputDefaultNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/OutputDefaultNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/OutputGroupNode.java b/examples/src/main/java/com/splunk/examples/explorer/OutputGroupNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/OutputGroupNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/OutputGroupNode.java
index 9b1cce2f..657aa7ba 100644
--- a/examples/explorer/com/splunk/sdk/explorer/OutputGroupNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/OutputGroupNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/OutputServerNode.java b/examples/src/main/java/com/splunk/examples/explorer/OutputServerNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/OutputServerNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/OutputServerNode.java
index a015f53c..94c86388 100644
--- a/examples/explorer/com/splunk/sdk/explorer/OutputServerNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/OutputServerNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/OutputSyslogNode.java b/examples/src/main/java/com/splunk/examples/explorer/OutputSyslogNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/OutputSyslogNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/OutputSyslogNode.java
index 98b2ee27..c5b05b92 100644
--- a/examples/explorer/com/splunk/sdk/explorer/OutputSyslogNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/OutputSyslogNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/PasswordNode.java b/examples/src/main/java/com/splunk/examples/explorer/PasswordNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/PasswordNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/PasswordNode.java
index 5ded6612..4b03f427 100644
--- a/examples/explorer/com/splunk/sdk/explorer/PasswordNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/PasswordNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/Program.java b/examples/src/main/java/com/splunk/examples/explorer/Program.java
similarity index 94%
rename from examples/explorer/com/splunk/sdk/explorer/Program.java
rename to examples/src/main/java/com/splunk/examples/explorer/Program.java
index 72807e84..025b8194 100644
--- a/examples/explorer/com/splunk/sdk/explorer/Program.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/Program.java
@@ -14,10 +14,10 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Service;
-import com.splunk.sdk.Command;
+import com.splunk.Command;
import javax.swing.SwingUtilities;
diff --git a/examples/explorer/com/splunk/sdk/explorer/PropertyInfo.java b/examples/src/main/java/com/splunk/examples/explorer/PropertyInfo.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/PropertyInfo.java
rename to examples/src/main/java/com/splunk/examples/explorer/PropertyInfo.java
index b710b266..1989ae93 100644
--- a/examples/explorer/com/splunk/sdk/explorer/PropertyInfo.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/PropertyInfo.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
public class PropertyInfo {
public Class datatype;
diff --git a/examples/explorer/com/splunk/sdk/explorer/PropertyList.java b/examples/src/main/java/com/splunk/examples/explorer/PropertyList.java
similarity index 93%
rename from examples/explorer/com/splunk/sdk/explorer/PropertyList.java
rename to examples/src/main/java/com/splunk/examples/explorer/PropertyList.java
index 9da04ffa..1981ed03 100644
--- a/examples/explorer/com/splunk/sdk/explorer/PropertyList.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/PropertyList.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import java.util.ArrayList;
import org.openide.nodes.PropertySupport;
@@ -39,7 +39,7 @@ public Sheet createSheet(Object object) {
}
}
catch (NoSuchMethodException e) {
- throw new RuntimeException(e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
}
sheet.put(props);
return sheet;
diff --git a/examples/explorer/com/splunk/sdk/explorer/ResourceNode.java b/examples/src/main/java/com/splunk/examples/explorer/ResourceNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/ResourceNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/ResourceNode.java
index 38f2f8d2..2f579df9 100644
--- a/examples/explorer/com/splunk/sdk/explorer/ResourceNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/ResourceNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Resource;
diff --git a/examples/explorer/com/splunk/sdk/explorer/RoleNode.java b/examples/src/main/java/com/splunk/examples/explorer/RoleNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/RoleNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/RoleNode.java
index d5ee2d59..f810c3a3 100644
--- a/examples/explorer/com/splunk/sdk/explorer/RoleNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/RoleNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/SavedSearchNode.java b/examples/src/main/java/com/splunk/examples/explorer/SavedSearchNode.java
similarity index 95%
rename from examples/explorer/com/splunk/sdk/explorer/SavedSearchNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/SavedSearchNode.java
index 4c754dd1..a042bc62 100644
--- a/examples/explorer/com/splunk/sdk/explorer/SavedSearchNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/SavedSearchNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
@@ -37,7 +37,7 @@ class SavedSearchNode extends EntityNode {
list.add(String.class, "getAlertThreshold");
list.add(String.class, "getAlertType");
list.add(String.class, "getCronSchedule");
- list.add(String.class, "getDescription");
+ list.add(String.class, "getDescriptionLabel");
list.add(int.class, "getDispatchBuckets");
list.add(String.class, "getDispatchEarliestTime");
list.add(String.class, "getDispatchLatestTime");
@@ -62,7 +62,7 @@ class SavedSearchNode extends EntityNode {
list.add(boolean.class, "isActionEmail");
list.add(boolean.class, "isActionPopulateLookup");
list.add(boolean.class, "isActionRss");
- list.add(boolean.class, "isActioncScript");
+ list.add(boolean.class, "isActionScript");
list.add(boolean.class, "isActionSummaryIndex");
list.add(boolean.class, "isDigestMode");
list.add(boolean.class, "isDisabled");
diff --git a/examples/explorer/com/splunk/sdk/explorer/ServiceKids.java b/examples/src/main/java/com/splunk/examples/explorer/ServiceKids.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/ServiceKids.java
rename to examples/src/main/java/com/splunk/examples/explorer/ServiceKids.java
index 1902e09b..216dd6bc 100644
--- a/examples/explorer/com/splunk/sdk/explorer/ServiceKids.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/ServiceKids.java
@@ -14,11 +14,10 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Service;
-import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
diff --git a/examples/explorer/com/splunk/sdk/explorer/ServiceNode.java b/examples/src/main/java/com/splunk/examples/explorer/ServiceNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/ServiceNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/ServiceNode.java
index 4189e51b..2c80c86b 100644
--- a/examples/explorer/com/splunk/sdk/explorer/ServiceNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/ServiceNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Service;
diff --git a/examples/explorer/com/splunk/sdk/explorer/SettingsNode.java b/examples/src/main/java/com/splunk/examples/explorer/SettingsNode.java
similarity index 97%
rename from examples/explorer/com/splunk/sdk/explorer/SettingsNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/SettingsNode.java
index 6aa16159..f6cfc105 100644
--- a/examples/explorer/com/splunk/sdk/explorer/SettingsNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/SettingsNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/StanzaNode.java b/examples/src/main/java/com/splunk/examples/explorer/StanzaNode.java
similarity index 98%
rename from examples/explorer/com/splunk/sdk/explorer/StanzaNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/StanzaNode.java
index 3c05b6ab..c5dc0753 100644
--- a/examples/explorer/com/splunk/sdk/explorer/StanzaNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/StanzaNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/explorer/com/splunk/sdk/explorer/StringArrayPropertyEditor.java b/examples/src/main/java/com/splunk/examples/explorer/StringArrayPropertyEditor.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/StringArrayPropertyEditor.java
rename to examples/src/main/java/com/splunk/examples/explorer/StringArrayPropertyEditor.java
index 0bfc4c14..82c642d4 100644
--- a/examples/explorer/com/splunk/sdk/explorer/StringArrayPropertyEditor.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/StringArrayPropertyEditor.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import java.beans.PropertyEditorSupport;
import java.util.Arrays;
diff --git a/examples/explorer/com/splunk/sdk/explorer/UserNode.java b/examples/src/main/java/com/splunk/examples/explorer/UserNode.java
similarity index 96%
rename from examples/explorer/com/splunk/sdk/explorer/UserNode.java
rename to examples/src/main/java/com/splunk/examples/explorer/UserNode.java
index b409fb57..a9f807f4 100644
--- a/examples/explorer/com/splunk/sdk/explorer/UserNode.java
+++ b/examples/src/main/java/com/splunk/examples/explorer/UserNode.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk.explorer;
+package com.splunk.examples.explorer;
import com.splunk.Entity;
diff --git a/examples/export/com/splunk/sdk/export/Program.java b/examples/src/main/java/com/splunk/examples/export/Program.java
similarity index 83%
rename from examples/export/com/splunk/sdk/export/Program.java
rename to examples/src/main/java/com/splunk/examples/export/Program.java
index e7a22bd0..55b298f1 100644
--- a/examples/export/com/splunk/sdk/export/Program.java
+++ b/examples/src/main/java/com/splunk/examples/export/Program.java
@@ -14,10 +14,9 @@
* under the License.
*/
-package com.splunk.sdk.export;
+package com.splunk.examples.export;
import com.splunk.*;
-import com.splunk.sdk.Command;
import java.nio.channels.FileChannel;
import java.io.File;
@@ -30,13 +29,12 @@
import java.util.HashMap;
import java.util.Map;
-
/**
* Export.java: export an splunk entire index in XML, CSV or JSON (4.3+). The
* return data is in strict descending time order.
*/
-// in recover mode, we will duplicate messages and meta data; however,
+// In recover mode, we will duplicate messages and meta data; however,
// this is not necessarily incorrect, just redundant information.
public class Program {
@@ -66,7 +64,7 @@ static Map getStartNextCSVEvent(int location, String str) {
while (eventEnd > 0) {
String substring = str.substring(eventStart, eventEnd);
String [] parts = substring.split(",");
- // test parts 0 and 1 of the CSV, for and time.qqq stamp
+ // Test parts 0 and 1 of the CSV, for and time.qqq stamp
try {
Integer.parseInt(parts[0]);
String timestamp = parts[1].replace("\"","");
@@ -78,7 +76,7 @@ static Map getStartNextCSVEvent(int location, String str) {
return pair;
}
catch (Exception e) {
- // if any of the fields accessed caused an exception, then
+ // If any of the fields accessed caused an exception, then
// we didn't have a valid start of event, so try again.
eventStart = str.indexOf("\n", eventEnd + 2);
eventEnd = str.indexOf("\"\n", eventStart + 1);
@@ -94,11 +92,11 @@ static int getCsvEventStart(String str) {
return -1;
lastTime = str.substring(pair.get("start"))
- .split(",")[1]
- .replace("\"","");
+ .split(",")[1]
+ .replace("\"","");
nextEventOffset = pair.get("end");
- // walk through events until time changes
+ // Walk through events until time changes.
while (pair.get("end") > 0) {
pair = getStartNextCSVEvent(pair.get("start"), str);
if (pair.get("end") < 0)
@@ -116,30 +114,31 @@ static int getCsvEventStart(String str) {
}
static int getXmlEventStart(String str) {
+ String resultPattern = "";
String timeStartPattern = "";
String timeEndPattern = "<";
String eventEndPattern = "";
- // get first event in this buffer. If no event end kick back
- int eventStart = str.indexOf("", eventStart)
+ eventStart = str.indexOf(resultPattern, eventStart+1);
+ eventEnd = str.indexOf(eventEndPattern, eventStart)
+ eventEndPattern.length();
if (eventEnd < 0)
return -1;
@@ -162,9 +161,9 @@ static int getJsonEventStart(String str) {
String timeKeyPattern = "\"_time\":\"";
String timeEndPattern = "\"";
String eventEndPattern = "\"},\n";
- String eventEndPattern2 = "\"}[]";
+ String eventEndPattern2 = "\"}[]"; // Old json output format bug
- // get first event in this buffer. If no event end kick back
+ // Get first event in this buffer. If no event end kick back.
int eventStart = str.indexOf("{\"_cd\":\"");
int eventEnd = str.indexOf(eventEndPattern, eventStart)
+ eventEndPattern.length();
@@ -180,7 +179,7 @@ static int getJsonEventStart(String str) {
lastTime = str.substring(timeStart, timeEnd);
nextEventOffset = eventEnd;
- // walk through events until time changes
+ // Walk through events until time changes.
eventStart = eventEnd;
while (eventEnd > 0) {
eventStart = str.indexOf("{\"_cd\":\"", eventStart+1);
@@ -224,7 +223,7 @@ static void cleanupTail(Writer out, String format) throws Exception {
else if (format.equals("xml"))
out.write("\n\n");
else
- out.write("[]\n");
+ out.write("\n]\n");
}
static void run(String[] argv) throws Exception {
@@ -246,8 +245,12 @@ static void run(String[] argv) throws Exception {
//
// N.B. json output only valid with 4.3+
- if (command.args.length == 0)
- throw new Error("Index-name required");
+ String indexName = null;
+ if (command.args.length == 0) {
+ System.out.println("Exporting main index");
+ indexName = "main";
+ } else
+ indexName = command.args[0];
if (command.args.length > 1) {
for (int index=1; index < command.args.length; index++) {
@@ -269,7 +272,7 @@ else if (command.args[index].equals("json"))
throw new Error("Export file exists, and no recover option");
if (recover && file.exists() && file.isFile()) {
- // chunk backwards through the file until we find valid
+ // Chunk backwards through the file until we find valid
// start time. If we can't find one just start over.
final int bufferSize = (64*1024);
RandomAccessFile raf = new RandomAccessFile(file, "rw");
@@ -289,7 +292,7 @@ else if (command.args[index].equals("json"))
}
if (fptr < 0)
- fptrEof = 0; // didn't find a valid event, so start over.
+ fptrEof = 0; // We didn't find a valid event, so start over.
else
args.put("latest_time", lastTime);
addEndOfLine = true;
@@ -300,33 +303,32 @@ else if (command.args[index].equals("json"))
if (!file.createNewFile())
throw new Error("Failed to create output file");
- // search args
- args.put("timeout", "60"); // don't keep search around
- args.put("output_mode", format); // output in specific format
- args.put("earliest_time", "0.000"); // always to beginning of index
- args.put("time_format", "%s.%Q"); // epoch time plus fraction
+ // Search args
+ args.put("timeout", "60"); // Don't keep search around
+ args.put("output_mode", format); // Output in specific format
+ args.put("earliest_time", "0.000"); // Always to beginning of index
+ args.put("time_format", "%s.%Q"); // Epoch time plus fraction
String search = null;
if (command.opts.containsKey("search")) {
search = (String)command.opts.get("search");
}
else {
- search = String.format("search index=%s *", command.args[0]);
+ search = String.format("search index=%s *", indexName);
}
- //System.out.println("search: " + search + ", args: " + args);
InputStream is = service.export(search, args);
- // use UTF8 sensitive reader/writers
- InputStreamReader isr = new InputStreamReader(is, "UTF8");
+ // Use UTF8 sensitive reader/writers
+ InputStreamReader isr = new InputStreamReader(is, "UTF-8");
FileOutputStream os = new FileOutputStream(file, true);
- Writer out = new OutputStreamWriter(os, "UTF8");
+ Writer out = new OutputStreamWriter(os, "UTF-8");
- // read/write 8k at a time if possible
+ // Read/write 8k at a time if possible
char [] xferBuffer = new char[8192];
boolean once = true;
- // if superfluous meta-data is not needed, or specifically
+ // If superfluous meta-data is not needed, or specifically
// wants to be removed, one would clean up the first read
// buffer on a format by format basis,
while (true) {
diff --git a/examples/src/main/java/com/splunk/examples/fluent_pivot/Program.java b/examples/src/main/java/com/splunk/examples/fluent_pivot/Program.java
new file mode 100644
index 00000000..79b70bf0
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/fluent_pivot/Program.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2014 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.examples.fluent_pivot;
+
+import com.splunk.*;
+
+public class Program {
+ public static void main(String[] argv) {
+ try {
+ run(argv);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static void run(String[] argsIn) throws Exception {
+ Command command;
+ Service service;
+
+ command = Command.splunk("input");
+ service = Service.connect(command.opts);
+
+ DataModel dataModel = service.getDataModels().get("internal_audit_logs");
+ DataModelObject searches = dataModel.getObject("searches");
+
+ System.out.print("Working with object " + searches.getDisplayName());
+ System.out.println(" in model " + dataModel.getDisplayName());
+ System.out.print(" Lineage: ");
+ for (String name : searches.getLineage()) {
+ System.out.print(" -> " + name);
+ }
+ System.out.println();
+ System.out.println(" Internal name: " + searches.getName());
+
+ Job firstFiveEntries = searches.runQuery("| head 5");
+ while (!firstFiveEntries.isDone()) {
+ Thread.sleep(100);
+ }
+
+ ResultsReaderXml results = new ResultsReaderXml(firstFiveEntries.getResults());
+ for (Event event : results) {
+ System.out.println(event.toString());
+ }
+
+ System.out.println("~~~~~~~~~~~~~~~~~~~~");
+ System.out.println("Pivoting on searches");
+
+ Pivot pivot = searches.createPivotSpecification().
+ addRowSplit("user", "Executing user").
+ addColumnSplit("exec_time", null, null, null, 4).
+ addCellValue("search", "Search Query", StatsFunction.DISTINCT_VALUES).
+ pivot();
+
+ System.out.println("Query for binning search queries by execution time and executing user:");
+ System.out.println(" " + pivot.getPrettyQuery());
+
+ Job pivotJob = pivot.run();
+ while (!pivotJob.isDone()) {
+ Thread.sleep(100);
+ }
+
+ results = new ResultsReaderXml(pivotJob.getResults());
+ for (Event event : results) {
+ System.out.println(event.toString());
+ }
+ }
+}
+
+
diff --git a/examples/src/main/java/com/splunk/examples/genevents/Program.java b/examples/src/main/java/com/splunk/examples/genevents/Program.java
new file mode 100644
index 00000000..247e1a30
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/genevents/Program.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2011 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.examples.genevents;
+
+import com.splunk.*;
+
+import java.io.*;
+import java.net.Socket;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Generate events into an index using either stream, submit or raw tcp
+ * methods.
+ */
+
+public class Program {
+
+ static String indexName =
+ "Name of index to send events to. If unspecified, 'default' is used";
+ static int ingestPort = 9002;
+ static String ingestMethod =
+ "Ingest events via method {stream, submit, tcp} (default: stream)";
+ static String tcpPort =
+ String.format("Input port for tcp ingest (default: %d)", ingestPort);
+ static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+
+ public static void main(String[] args) {
+ try {
+ run(args);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static String makeEvent(String stamp, int i, int j) {
+ return String.format("%s: event bunch %d, number %d\n", stamp, i, j);
+ }
+
+ static void buildRules(Command command, String[] argsIn) {
+ command.addRule("index", String.class, indexName);
+ command.addRule("itype", String.class, ingestMethod);
+ command.addRule("iport", String.class, tcpPort);
+ command.parse(argsIn);
+ }
+
+ static void run(String[] argsIn) throws Exception {
+
+ Command command;
+ int count;
+ Index index = null;
+ String ingest;
+ String iname;
+ List ingestTypes = Arrays.asList("submit", "stream", "tcp");
+ OutputStream ostream;
+ Receiver receiver = null;
+ Service service;
+ Socket stream = null;
+ Writer writerOut = null;
+
+ command = Command.splunk("genevents");
+ buildRules(command, argsIn);
+ service = Service.connect(command.opts);
+
+ // Determine ingest method and other input arguments.
+ iname = null;
+ ingest = "stream";
+ if (command.opts.containsKey("index")) {
+ iname = (String)command.opts.get("index");
+ }
+ if (command.opts.containsKey("itype"))
+ ingest = (String)command.opts.get("itype");
+ if (command.opts.containsKey("iport")) {
+ ingestPort = Integer.parseInt((String)command.opts.get("iport"));
+ }
+
+ // Validate
+ if (!ingestTypes.contains(ingest)) {
+ Command.error("Method '"+ingest+"' must be in set: "+ingestTypes);
+ }
+
+ if (iname != null) {
+ index = service.getIndexes().get(iname);
+ if (index == null) {
+ Command.error("Index '" + iname + "' was not found.");
+ }
+ } else {
+ receiver = service.getReceiver();
+ }
+
+
+ // For stream and tcp, they both require a socket, though setup
+ // slightly differently.
+ if (ingest.equals("stream") || ingest.equals("tcp")) {
+ if (ingest.equals("stream"))
+ try {
+ // A specific index or not?
+ if (iname != null)
+ stream = index.attach();
+ else
+ stream = receiver.attach();
+ }
+ catch (NullPointerException e) {
+ System.out.println("Failed to attach to index.");
+ System.exit(3);
+ }
+ else {
+ // Create a tcp input if one does not already exist.
+ String inputName = String.valueOf(ingestPort);
+ TcpInput tcpInput = (TcpInput)service.getInputs().get(inputName);
+ if (tcpInput == null) {
+ tcpInput = (TcpInput)service.getInputs().create(
+ inputName, InputKind.Tcp);
+ }
+ stream = tcpInput.attach();
+ }
+ ostream = stream.getOutputStream();
+ writerOut = new OutputStreamWriter(ostream, "UTF-8");
+ }
+
+ // Generate 10 batches of 5000 events each.
+ count = 0;
+ for (int i=0; i<10; i++) {
+ for (int j=0; j<5000; j++) {
+ Date date = new Date();
+ String lastEvent = makeEvent(dateFormat.format(date), i, j);
+ if (ingest.equals("stream") || ingest.equals("tcp"))
+ writerOut.write(lastEvent);
+ else
+ if (iname != null)
+ index.submit(lastEvent);
+ else
+ receiver.submit(lastEvent);
+ count++;
+ }
+ System.out.println("Submitted "+count+" events, using "+ingest);
+ }
+
+ // Flush and close stream on completion
+ if (ingest.equals("stream") || ingest.equals("tcp")) {
+ writerOut.flush();
+ writerOut.close();
+ stream.close();
+ }
+ }
+}
diff --git a/examples/src/main/java/com/splunk/examples/get_job/Program.java b/examples/src/main/java/com/splunk/examples/get_job/Program.java
new file mode 100644
index 00000000..3656ed1d
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/get_job/Program.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015 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.examples.get_job;
+
+import com.splunk.*;
+
+/**
+ * This example shows a better way to retrieve a Job by its sid
+ * using the new getJob() method.
+ *
+ * Previously, the only way to do this would be the following:
+ *
+ * Job job = service.getJobs().get(sid);
+ *
+ * The above has a significant overhead of getting all search jobs from
+ * the Splunk REST API in order to get a single Job.
+ *
+ */
+
+public class Program {
+ public static void main(String[] args) {
+ Command command = Command.splunk("info").parse(args);
+ Service service = Service.connect(command.opts);
+
+ String sid = service.search("search index=_internal | head 5").getSid();
+ Job job = service.getJob(sid);
+
+ while (!job.isDone()) {
+ job.refresh();
+ try {
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ System.out.println("Number of events found: " + job.getEventCount());
+ }
+}
\ No newline at end of file
diff --git a/examples/index/com/splunk/sdk/index/Program.java b/examples/src/main/java/com/splunk/examples/index/Program.java
similarity index 80%
rename from examples/index/com/splunk/sdk/index/Program.java
rename to examples/src/main/java/com/splunk/examples/index/Program.java
index 4f3b03ab..d3761d54 100644
--- a/examples/index/com/splunk/sdk/index/Program.java
+++ b/examples/src/main/java/com/splunk/examples/index/Program.java
@@ -14,12 +14,13 @@
* under the License.
*/
-package com.splunk.sdk.index;
+package com.splunk.examples.index;
import com.splunk.EntityCollection;
import com.splunk.Index;
import com.splunk.Service;
-import com.splunk.sdk.Command;
+import com.splunk.Command;
+import com.splunk.SplunkException;
public class Program {
private static void list(Service service) {
@@ -60,12 +61,22 @@ public static void main(String[] args) {
return;
}
- Index index = (Index)indexes.get(name);
+ Index index = indexes.get(name);
if (index == null)
Command.error("Index '" + name + "' does not exists");
- if (action.equals("clean"))
- index.clean();
+ if (action.equals("clean")) {
+ try {
+ index.clean(180); // Timeout after 3 minutes.
+ } catch (SplunkException e) {
+ if (e.getCode() == SplunkException.INTERRUPTED) {
+ // User pressed Ctrl-C
+ return;
+ } else {
+ throw e;
+ }
+ }
+ }
else if (action.equals("disable"))
index.disable();
else if (action.equals("enable"))
diff --git a/examples/info/com/splunk/sdk/info/Program.java b/examples/src/main/java/com/splunk/examples/info/Program.java
similarity index 95%
rename from examples/info/com/splunk/sdk/info/Program.java
rename to examples/src/main/java/com/splunk/examples/info/Program.java
index a1546629..d249238b 100644
--- a/examples/info/com/splunk/sdk/info/Program.java
+++ b/examples/src/main/java/com/splunk/examples/info/Program.java
@@ -14,10 +14,9 @@
* under the License.
*/
-package com.splunk.sdk.info;
+package com.splunk.examples.info;
import com.splunk.*;
-import com.splunk.sdk.Command;
public class Program {
public static void main(String[] args) {
diff --git a/examples/src/main/java/com/splunk/examples/input/Program.java b/examples/src/main/java/com/splunk/examples/input/Program.java
new file mode 100644
index 00000000..9b6d2c66
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/input/Program.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2011 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.examples.input;
+
+import com.splunk.*;
+
+/**
+ * Generate events into an index using either stream, submit or raw tcp
+ * methods.
+ */
+
+public class Program {
+
+ public static void main(String[] args) {
+ try {
+ run(args);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static void DisplaySpecificInput(Input input) {
+ InputKind inputKind = input.getKind();
+
+ System.out.println(" **type specific settings");
+
+ if (inputKind == InputKind.Monitor) {
+ MonitorInput monitorInput = (MonitorInput) input;
+ System.out.println(
+ " file count: " + monitorInput.getFileCount());
+ System.out.println(
+ " host: " + monitorInput.getHost());
+ System.out.println(
+ " index: " + monitorInput.getIndex());
+ System.out.println(
+ " receive buffer: " + monitorInput.getRcvBuf());
+ } else if (inputKind == InputKind.Script) {
+ ScriptInput scriptInput = (ScriptInput) input;
+ System.out.println(
+ " group: " + scriptInput.getGroup());
+ System.out.println(
+ " host: " + scriptInput.getHost());
+ System.out.println(
+ " index: " + scriptInput.getIndex());
+ System.out.println(
+ " interval: " + scriptInput.getInterval());
+ System.out.println(
+ " receive buffer: " + scriptInput.getRcvBuf());
+ } else if (inputKind == InputKind.Tcp) {
+ TcpInput tcpInput = (TcpInput) input;
+ System.out.println(
+ " connection host: " + tcpInput.getConnectionHost());
+ System.out.println(
+ " group: " + tcpInput.getGroup());
+ System.out.println(
+ " host: " + tcpInput.getHost());
+ System.out.println(
+ " index: " + tcpInput.getIndex());
+ System.out.println(
+ " queue: " + tcpInput.getQueue());
+ System.out.println(
+ " receive buffer: " + tcpInput.getRcvBuf());
+ System.out.println(
+ " restrict to host:" + tcpInput.getRestrictToHost());
+ System.out.println(
+ " source: " + tcpInput.getSource());
+ System.out.println(
+ " source type: " + tcpInput.getSourceType());
+ System.out.println(
+ " SSL: " + tcpInput.getSSL());
+ } else if (inputKind == InputKind.TcpSplunk) {
+ TcpSplunkInput tcpSplunkInput = (TcpSplunkInput) input;
+ System.out.println(
+ " connection host: " + tcpSplunkInput.getConnectionHost());
+ System.out.println(
+ " group: " + tcpSplunkInput.getGroup());
+ System.out.println(
+ " host: " + tcpSplunkInput.getHost());
+ System.out.println(
+ " index: " + tcpSplunkInput.getIndex());
+ System.out.println(
+ " queue: " + tcpSplunkInput.getQueue());
+ System.out.println(
+ " receive buffer: " + tcpSplunkInput.getRcvBuf());
+ System.out.println(
+ " source: " + tcpSplunkInput.getSource());
+ System.out.println(
+ " source type: " + tcpSplunkInput.getSourceType());
+ System.out.println(
+ " SSL: " + tcpSplunkInput.getSSL());
+ } else if (inputKind == InputKind.Udp) {
+ UdpInput udpInput = (UdpInput) input;
+ System.out.println(
+ " connection host: " + udpInput.getConnectionHost());
+ System.out.println(
+ " group: " + udpInput.getGroup());
+ System.out.println(
+ " host: " + udpInput.getHost());
+ System.out.println(
+ " index: " + udpInput.getIndex());
+ System.out.println(
+ " queue: " + udpInput.getQueue());
+ System.out.println(
+ " receive buffer: " + udpInput.getRcvBuf());
+ System.out.println(
+ " source: " + udpInput.getSource());
+ System.out.println(
+ " source type: " + udpInput.getSourceType());
+ System.out.println(
+ " no timestamp append:" +
+ udpInput.getNoAppendingTimeStamp());
+ System.out.println(
+ " no priority stripping:" +
+ udpInput.getNoPriorityStripping());
+ } else if (inputKind == InputKind.WindowsActiveDirectory) {
+ WindowsActiveDirectoryInput windowsActiveDirectoryInput =
+ (WindowsActiveDirectoryInput) input;
+ System.out.println(
+ " index: " +
+ windowsActiveDirectoryInput.getIndex());
+ System.out.println(
+ " monitor subtree: " +
+ windowsActiveDirectoryInput.getMonitorSubtree());
+ System.out.println(
+ " starting node: " +
+ windowsActiveDirectoryInput.getStartingNode());
+ System.out.println(
+ " target DC: " +
+ windowsActiveDirectoryInput.getTargetDc());
+ } else if (inputKind == InputKind.WindowsEventLog) {
+ WindowsEventLogInput windowsEventLogInput =
+ (WindowsEventLogInput) input;
+ System.out.println(
+ " hosts: " +
+ windowsEventLogInput.getHosts());
+ System.out.println(
+ " index: " +
+ windowsEventLogInput.getIndex());
+ System.out.println(
+ " local name: " +
+ windowsEventLogInput.getLocalName());
+ String[] logs = windowsEventLogInput.getLogs();
+ System.out.println(" logs:");
+ if (logs != null)
+ for (String log: logs) {
+ System.out.println(" " + log);
+ }
+ System.out.println(
+ " lookup host: " +
+ windowsEventLogInput.getLookupHost());
+ } else if (inputKind == InputKind.WindowsPerfmon) {
+ WindowsPerfmonInput windowsPerfmonInput =
+ (WindowsPerfmonInput) input;
+ System.out.println(
+ " counters: " +
+ windowsPerfmonInput.getCounters());
+ System.out.println(
+ " index: " +
+ windowsPerfmonInput.getIndex());
+ System.out.println(
+ " instances: " +
+ windowsPerfmonInput.getInstances());
+ System.out.println(
+ " interval: " +
+ windowsPerfmonInput.getInterval());
+ System.out.println(
+ " object: " +
+ windowsPerfmonInput.getObject());
+ } else if (inputKind == InputKind.WindowsRegistry) {
+ WindowsRegistryInput windowsRegistryInput =
+ (WindowsRegistryInput) input;
+ System.out.println(
+ " baseline: " +
+ windowsRegistryInput.getBaseline());
+ System.out.println(
+ " hive: " +
+ windowsRegistryInput.getHive());
+ System.out.println(
+ " index: " +
+ windowsRegistryInput.getIndex());
+ System.out.println(
+ " monitor subnodes:" +
+ windowsRegistryInput.getMonitorSubnodes());
+ System.out.println(
+ " process: " +
+ windowsRegistryInput.getProc());
+ System.out.println(
+ " type: " +
+ windowsRegistryInput.getType());
+ } else if (inputKind == InputKind.WindowsWmi) {
+ WindowsWmiInput windowsWmiInput = (WindowsWmiInput) input;
+ System.out.println(
+ " WMI input: " +
+ windowsWmiInput.getClasses());
+ String[] fields = windowsWmiInput.getFields();
+ System.out.println(" fields:");
+ for (String field: fields) {
+ System.out.println(" " + field);
+ }
+ System.out.println(
+ " index: " +
+ windowsWmiInput.getIndex());
+
+ String[] instances = windowsWmiInput.getInstances();
+ System.out.println(" instances:");
+ for (String instance: instances) {
+ System.out.println(" " + instance);
+ }
+ System.out.println(
+ " interval: " +
+ windowsWmiInput.getInterval());
+ System.out.println(
+ " local name: " +
+ windowsWmiInput.getLocalName());
+ System.out.println(
+ " lookup host: " +
+ windowsWmiInput.getLookupHost());
+ System.out.println(
+ " server: " +
+ windowsWmiInput.getServers());
+ System.out.println(
+ " WQL: " + windowsWmiInput.getWql());
+ }
+ }
+
+ static void run(String[] argsIn) throws Exception {
+
+ Command command;
+ Service service;
+
+ command = Command.splunk("input");
+ service = Service.connect(command.opts);
+
+ InputCollection inputs = service.getInputs();
+
+ // Iterate inputs and make sure we can read them.
+ for (Input input : inputs.values()) {
+ System.out.println("Input name: " + input.getName());
+ System.out.println(" title: " + input.getTitle());
+ System.out.println(" path: " + input.getPath());
+ System.out.println(" type: " + input.getKind());
+ DisplaySpecificInput(input);
+ System.out.println("\n\n");
+ }
+ }
+}
diff --git a/examples/src/main/java/com/splunk/examples/pivot/Program.java b/examples/src/main/java/com/splunk/examples/pivot/Program.java
new file mode 100644
index 00000000..bcb55dec
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/pivot/Program.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2014 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.examples.pivot;
+
+import com.splunk.*;
+
+public class Program {
+ public static void main(String[] argv) {
+ try {
+ run(argv);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static void run(String[] argsIn) throws Exception {
+ Command command;
+ Service service;
+
+ command = Command.splunk("input");
+ service = Service.connect(command.opts);
+
+ DataModel dataModel = service.getDataModels().get("internal_audit_logs");
+ DataModelObject searches = dataModel.getObject("searches");
+
+ System.out.print("Working with object " + searches.getDisplayName());
+ System.out.println(" in model " + dataModel.getDisplayName());
+ System.out.print(" Lineage: ");
+ for (String name : searches.getLineage()) {
+ System.out.print(" -> " + name);
+ }
+ System.out.println();
+ System.out.println(" Internal name: " + searches.getName());
+
+ Job firstFiveEntries = searches.runQuery("| head 5");
+ while (!firstFiveEntries.isDone()) {
+ Thread.sleep(100);
+ }
+
+ ResultsReaderXml results = new ResultsReaderXml(firstFiveEntries.getResults());
+ for (Event event : results) {
+ System.out.println(event.toString());
+ }
+
+ System.out.println("~~~~~~~~~~~~~~~~~~~~");
+ System.out.println("Pivoting on searches");
+
+ PivotSpecification pivotSpecification = searches.createPivotSpecification();
+
+ pivotSpecification.addRowSplit("user", "Executing user");
+ pivotSpecification.addColumnSplit("exec_time", null, null, null, 4);
+ pivotSpecification.addCellValue("search", "Search Query", StatsFunction.DISTINCT_VALUES);
+
+ Pivot pivot = pivotSpecification.pivot();
+ System.out.println("Query for binning search queries by execution time and executing user:");
+ System.out.println(" " + pivot.getPrettyQuery());
+
+ Job pivotJob = pivot.run();
+ while (!pivotJob.isDone()) {
+ Thread.sleep(100);
+ }
+
+ results = new ResultsReaderXml(pivotJob.getResults());
+ for (Event event : results) {
+ System.out.println(event.toString());
+ }
+
+ }
+}
+
+
diff --git a/examples/src/main/java/com/splunk/examples/random_numbers/Program.java b/examples/src/main/java/com/splunk/examples/random_numbers/Program.java
new file mode 100644
index 00000000..f21e02c0
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/random_numbers/Program.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2013 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.examples.random_numbers;
+
+import com.splunk.modularinput.*;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+import java.util.Random;
+
+// All modular inputs should inherit from the abstract base class com.splunk.modularinput.Script. They must override
+// the getScheme and streamEvents methods, and, if the scheme returned by getScheme had
+// Scheme.setUseExternalValidation(true) called on it, the validateInput method. The user must provide a main
+// method since static methods can't be inherited in Java. However, the main is very simple.
+public class Program extends Script {
+
+ // All main methods for modular inputs need only be one line. They can't be inherited because they must create
+ // an instance of this class, and the abstract base class has no way to do so. So if the class were called MyInput,
+ // the one line would be
+ //
+ // new MyInput().run(args);
+ //
+ public static void main(String[] args) {
+ new Program().run(args);
+ }
+
+ // When Splunk starts, it looks for all the modular inputs defined by its configuration, and tries to run them
+ // with the argument --scheme. Splunkd expects the modular inputs to print a description of the input in XML
+ // on stdout. The modular input framework takes care of all the details of formatting XML and printing it. The
+ // user need only override getScheme and return a new Scheme object.
+ @Override
+ public Scheme getScheme() {
+ // "random_numbers" is the name Splunk will display to users for this input.
+ Scheme scheme = new Scheme("random_numbers");
+
+ scheme.setDescription("Generates events containing a random number.");
+ // If you set external validation, without overriding validateInput, the script will accept anything as valid.
+ // Generally you only need external validation if there are relationships you must maintain among the
+ // parameters, such as requiring min to be less than max in this example, or you need to check that some
+ // resource is reachable or valid. Otherwise, Splunk lets you specify a validation string for each argument
+ // and will run validation internally using that string.
+ scheme.setUseExternalValidation(true);
+ scheme.setUseSingleInstance(true);
+
+ Argument minArgument = new Argument("min");
+ minArgument.setDataType(Argument.DataType.NUMBER);
+ minArgument.setDescription("Minimum value to be produced by this input.");
+ minArgument.setRequiredOnCreate(true);
+ // If you are not using external validation, you would add something like:
+ //
+ // setValidation("min > 0");
+ scheme.addArgument(minArgument);
+
+ Argument maxArgument = new Argument("max");
+ maxArgument.setDataType(Argument.DataType.NUMBER);
+ maxArgument.setDescription("Maximum value to be produced by this input.");
+ maxArgument.setRequiredOnCreate(true);
+ scheme.addArgument(maxArgument);
+
+ return scheme; // ...and don't forget to return the scheme.
+ }
+
+ // In this example we are using external validation, since we want max to always be greater than min.
+ // If validateInput does not throw an Exception, the input is assumed to be valid. Otherwise it prints the
+ // exception as an error message when telling splunkd that the configuration is not valid.
+ //
+ // When using external validation, after splunkd calls the modular input with --scheme to get a scheme, it calls it
+ // again with --validate-arguments for each instance of the modular input in its configuration files, feeding XML
+ // on stdin to the modular input to get it to do validation. It calls it the same way again whenever a modular
+ // input's configuration is changed.
+ @Override
+ public void validateInput(ValidationDefinition definition) throws Exception {
+ // Get the values of the two parameters. There are also methods getFloat, getInt, getBoolean, etc.,
+ // and getValue to get the string representation.
+ double min = ((SingleValueParameter)definition.getParameters().get("min")).getDouble();
+ double max = ((SingleValueParameter)definition.getParameters().get("max")).getDouble();
+
+ if (min >= max) {
+ throw new Exception("min must be less than max; found min=" + Double.toString(min) +
+ ", max=" + Double.toString(max));
+ }
+ }
+
+ // Finally, the real action: splunk calls the modular input with no arguments, streams a bunch of XML describing
+ // the inputs to stdin, and waits for XML on stdout describing events.
+ //
+ // If you set setUseSingleInstance(true) on the scheme in getScheme, it will pass all the instances of this input
+ // to a single instance of this script and it's your job to handle them all. Otherwise, it starts a JVM for each
+ // instance of the input.
+ //
+ // We are using a single instance, and starting a thread for each instance of the modular input. For scripts that
+ // are not single instance, it is simpler to do the work directly in the streamEvents method.
+ @Override
+ public void streamEvents(InputDefinition inputs, EventWriter ew) throws MalformedDataException,
+ XMLStreamException, IOException {
+ for (String inputName : inputs.getInputs().keySet()) {
+ // We get the parameters for each input and start a new thread for each one. All the real work
+ // happens in the Generator class below.
+ double min = ((SingleValueParameter)inputs.getInputs().get(inputName).get("min")).getDouble();
+ double max = ((SingleValueParameter)inputs.getInputs().get(inputName).get("max")).getDouble();
+
+ Thread t = new Thread(new Generator(ew, inputName, min, max));
+ t.run();
+ }
+ }
+
+ // A Runnable that generates events with a random number in the proper range every half second. All the important
+ // stuff to look at is in the run method.
+ class Generator implements Runnable {
+ private double min, max;
+ EventWriter ew;
+ String inputName;
+
+ public Generator(EventWriter ew, String inputName, double min, double max) {
+ super();
+ this.min = min;
+ this.max = max;
+ this.ew = ew;
+ this.inputName = inputName;
+ }
+
+ public void run() {
+ // First we log an INFO message that this thread has started. This will show up in splunkd.log and in
+ // Splunk's _internal index.
+
+ // EventWriter provides both log and synchronizedLog (one a synchronized version of the other). In
+ // this case, synchronizing at the level of each log message and event is exactly what we want. In
+ // more complicated cases, you may want to use the unsynchronized version and do your own
+ // synchronization.
+ ew.synchronizedLog(EventWriter.INFO, "Random number generator " + inputName +
+ " started, generating numbers between " +
+ Double.toString(min) + " and " + Double.toString(max));
+
+ final Random randomGenerator = new Random();
+
+ while (true) {
+ // Write a new event. The minimum that you must set on an event is the stanza it is supposed to
+ // go to (which you can skip if your modular input is not single instance, and the data of the
+ // event.
+ Event event = new Event();
+ event.setStanza(inputName);
+ event.setData("number=" + (randomGenerator.nextDouble() * (max - min) + min));
+
+ try {
+ ew.writeEvent(event);
+ } catch (MalformedDataException e) {
+ ew.synchronizedLog(EventWriter.ERROR, "MalformedDataException in writing event to input" +
+ inputName + ": " + e.toString());
+ }
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ }
+ }
+}
diff --git a/examples/src/main/java/com/splunk/examples/random_numbers/random_numbers/README/inputs.conf.spec b/examples/src/main/java/com/splunk/examples/random_numbers/random_numbers/README/inputs.conf.spec
new file mode 100644
index 00000000..2b507cea
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/random_numbers/random_numbers/README/inputs.conf.spec
@@ -0,0 +1,5 @@
+[random_numbers://default]
+*Generates events containing a random floating point number.
+
+min =
+max =
diff --git a/examples/src/main/java/com/splunk/examples/random_numbers/random_numbers/default/app.conf b/examples/src/main/java/com/splunk/examples/random_numbers/random_numbers/default/app.conf
new file mode 100644
index 00000000..057bd137
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/random_numbers/random_numbers/default/app.conf
@@ -0,0 +1,12 @@
+[install]
+is_configured = 0
+
+[ui]
+is_visible = 1
+label = random-numbers
+
+[launcher]
+author = Fred Ross
+description =
+version = 1.0
+
diff --git a/examples/search/com/splunk/sdk/search/Program.java b/examples/src/main/java/com/splunk/examples/search/Program.java
similarity index 65%
rename from examples/search/com/splunk/sdk/search/Program.java
rename to examples/src/main/java/com/splunk/examples/search/Program.java
index fea08cef..f2fbd25a 100644
--- a/examples/search/com/splunk/sdk/search/Program.java
+++ b/examples/src/main/java/com/splunk/examples/search/Program.java
@@ -14,19 +14,15 @@
* under the License.
*/
-package com.splunk.sdk.search;
+package com.splunk.examples.search;
-import com.splunk.Args;
-import com.splunk.HttpException;
-import com.splunk.Job;
-import com.splunk.sdk.Command;
-import com.splunk.Service;
+import com.splunk.*;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
+import java.util.HashMap;
// Note: not all search parameters are exposed to the CLI for this example.
public class Program {
@@ -34,20 +30,24 @@ public class Program {
"events", "results", "preview", "searchlog", "summary", "timeline"
};
- static String earliestTime = "Search earliest time";
+ static String earliestTimeText = "Search earliest time";
static String fieldListText =
"A comma-separated list of the fields to return";
- static String latestTime = "Search latest time";
+ static String latestTimeText = "Search latest time";
static String offset =
- "The first result (inclusive) from which to begin returning data. (default: 0)";
+ "The first result (inclusive) from which to begin returning data. " +
+ "(default: 0)";
static String outputText =
- "Which search results to output {events, results, preview, searchlog, summary, timeline} (default: results)";
+ "Which search results to output {events, results, preview, searchlog," +
+ " summary, timeline} (default: results)";
static String outputModeText =
"Search output format {csv, raw, json, xml} (default: xml)";
static String resultsCount =
"The maximum number of results to return (default: 100)";
+ static String readerText = "Use ResultsReader";
static String statusBucketsText =
"Number of status buckets to use for search (default: 0)";
+ static String verboseString = "Display search progress";
public static void main(String[] args) {
try {
@@ -59,17 +59,18 @@ public static void main(String[] args) {
}
}
- static void run(String[] args) throws IOException {
+ static void run(String[] args) throws Exception {
Command command = Command.splunk("search");
command.addRule("count", Integer.class, resultsCount);
- command.addRule("earliest_time", String.class, earliestTime);
+ command.addRule("earliest_time", String.class, earliestTimeText);
command.addRule("field_list", String.class, fieldListText);
- command.addRule("latest_time", String.class, latestTime);
+ command.addRule("latest_time", String.class, latestTimeText);
command.addRule("offset", Integer.class, offset);
command.addRule("output", String.class, outputText);
command.addRule("output_mode", String.class, outputModeText);
+ command.addRule("reader", readerText);
command.addRule("status_buckets", Integer.class, statusBucketsText);
- command.addRule("verbose", "Display search progress");
+ command.addRule("verbose", verboseString);
command.parse(args);
if (command.args.length != 1)
@@ -90,7 +91,7 @@ static void run(String[] args) throws IOException {
String latestTime = null;
if (command.opts.containsKey("latest_time"))
- earliestTime = (String)command.opts.get("latest_time");
+ latestTime = (String)command.opts.get("latest_time");
int offset = 0;
if (command.opts.containsKey("offset"))
@@ -117,12 +118,10 @@ static void run(String[] args) throws IOException {
// Check the syntax of the query.
try {
- Args parseArgs = new Args("parse_only", true);
- service.parse(query, parseArgs);
+ service.parse(query, new Args("parse_only", true));
}
catch (HttpException e) {
- String detail = e.getDetail();
- Command.error("query '%s' is invalid: %s", query, detail);
+ Command.error("query '%s' is invalid: %s", query, e.getDetail());
}
// Create a search job for the given query & query arguments.
@@ -135,16 +134,14 @@ static void run(String[] args) throws IOException {
queryArgs.put("latest_time", latestTime);
if (statusBuckets > 0)
queryArgs.put("status_buckets", statusBuckets);
+
Job job = service.getJobs().create(query, queryArgs);
// Wait until results are available.
- boolean status = false;
- while (true) {
- if (job.isDone())
- break;
-
- // If no outputs are available, optionally print status and wait.
- if (verbose) {
+ boolean didPrintAStatusLine = false;
+ while (!job.isDone()) {
+ // If no outputs are available, optionally print status
+ if (verbose && job.isReady()) {
float progress = job.getDoneProgress() * 100.0f;
int scanned = job.getScanCount();
int matched = job.getEventCount();
@@ -152,23 +149,20 @@ static void run(String[] args) throws IOException {
System.out.format(
"\r%03.1f%% done -- %d scanned -- %d matched -- %d results",
progress, scanned, matched, results);
- status = true;
+ didPrintAStatusLine = true;
}
- try { Thread.sleep(2000); }
- catch (InterruptedException e) {}
-
- job.refresh();
+ Thread.sleep(1000);
}
- if (status) System.out.println("");
-
- InputStream stream = null;
+ if (didPrintAStatusLine)
+ System.out.println("");
Args outputArgs = new Args();
outputArgs.put("count", resultsCount);
outputArgs.put("offset", offset);
outputArgs.put("output_mode", outputMode);
+ InputStream stream;
if (output.equals("results"))
stream = job.getResults(outputArgs);
else if (output.equals("events"))
@@ -181,23 +175,59 @@ else if (output.equals("summary"))
stream = job.getSummary(outputArgs);
else if (output.equals("timeline"))
stream = job.getTimeline(outputArgs);
- else assert(false);
-
- InputStreamReader reader = new InputStreamReader(stream);
- OutputStreamWriter writer = new OutputStreamWriter(System.out);
-
- int size = 1024;
- char[] buffer = new char[size];
- while (true) {
- int count = reader.read(buffer);
- if (count == -1) break;
- writer.write(buffer, 0, count);
+ else
+ throw new IllegalArgumentException(
+ "Unrecognized output type: " + output);
+
+ boolean useReader = command.opts.containsKey("reader");
+ if (useReader) {
+ ResultsReader resultsReader;
+ if (outputMode.equals("xml"))
+ resultsReader = new ResultsReaderXml(stream);
+ else if (outputMode.equals("json"))
+ resultsReader = new ResultsReaderJson(stream);
+ else if (outputMode.equals("csv"))
+ resultsReader = new ResultsReaderCsv(stream);
+ else
+ throw new IllegalArgumentException(
+ "Unrecognized output mode: " + outputMode);
+
+ try {
+ HashMap event;
+ while ((event = resultsReader.getNextEvent()) != null) {
+ System.out.println("EVENT:********");
+ for (String key : event.keySet())
+ System.out.println(" " + key + " --> " + event.get(key));
+ }
+ }
+ finally {
+ resultsReader.close();
+ }
+ }
+ else {
+ InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
+ try {
+ OutputStreamWriter writer = new OutputStreamWriter(System.out);
+ try {
+ int size = 1024;
+ char[] buffer = new char[size];
+ while (true) {
+ int count = reader.read(buffer);
+ if (count == -1) break;
+ writer.write(buffer, 0, count);
+ }
+
+ writer.write("\n");
+ }
+ finally {
+ writer.close();
+ }
+ }
+ finally {
+ reader.close();
+ }
}
-
- writer.write("\n");
- writer.close();
- reader.close();
job.cancel();
}
-}
+}
\ No newline at end of file
diff --git a/examples/search_blocking/com/splunk/sdk/search_blocking/Program.java b/examples/src/main/java/com/splunk/examples/search_blocking/Program.java
similarity index 74%
rename from examples/search_blocking/com/splunk/sdk/search_blocking/Program.java
rename to examples/src/main/java/com/splunk/examples/search_blocking/Program.java
index bcce8a7e..b01e946f 100644
--- a/examples/search_blocking/com/splunk/sdk/search_blocking/Program.java
+++ b/examples/src/main/java/com/splunk/examples/search_blocking/Program.java
@@ -14,19 +14,16 @@
* under the License.
*/
-package com.splunk.sdk.search_blocking;
+package com.splunk.examples.search_blocking;
-import com.splunk.Args;
-import com.splunk.HttpException;
-import com.splunk.Job;
-import com.splunk.sdk.Command;
-import com.splunk.Service;
+import com.splunk.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
+import java.util.HashMap;
// Note: not all search parameters are exposed to the CLI for this example.
public class Program {
@@ -34,18 +31,21 @@ public class Program {
"events", "results", "preview", "searchlog", "summary", "timeline"
};
- static String earliestTime = "Search earliest time";
+ static String earliestTimeText = "Search earliest time";
static String fieldListText =
"A comma-separated list of the fields to return";
- static String latestTime = "Search latest time";
+ static String latestTimeText = "Search latest time";
static String offset =
- "The first result (inclusive) from which to begin returning data. (default: 0)";
+ "The first result (inclusive) from which to begin returning data. " +
+ "(default: 0)";
static String outputText =
- "Which search results to output {events, results, preview, searchlog, summary, timeline} (default: results)";
+ "Which search results to output {events, results, preview, searchlog," +
+ " summary, timeline} (default: results)";
static String outputModeText =
"Search output format {csv, raw, json, xml} (default: xml)";
static String resultsCount =
"The maximum number of results to return (default: 100)";
+ static String rawText = "Set to 1 if raw events are displayed (default 1)";
static String statusBucketsText =
"Number of status buckets to use for search (default: 0)";
@@ -62,12 +62,13 @@ public static void main(String[] args) {
static void run(String[] args) throws IOException {
Command command = Command.splunk("search");
command.addRule("count", Integer.class, resultsCount);
- command.addRule("earliest_time", String.class, earliestTime);
+ command.addRule("earliest_time", String.class, earliestTimeText);
command.addRule("field_list", String.class, fieldListText);
- command.addRule("latest_time", String.class, latestTime);
+ command.addRule("latest_time", String.class, latestTimeText);
command.addRule("offset", Integer.class, offset);
command.addRule("output", String.class, outputText);
command.addRule("output_mode", String.class, outputModeText);
+ command.addRule("raw", Integer.class, rawText);
command.addRule("status_buckets", Integer.class, statusBucketsText);
command.parse(args);
@@ -89,7 +90,7 @@ static void run(String[] args) throws IOException {
String latestTime = null;
if (command.opts.containsKey("latest_time"))
- earliestTime = (String)command.opts.get("latest_time");
+ latestTime = (String)command.opts.get("latest_time");
int offset = 0;
if (command.opts.containsKey("offset"))
@@ -133,7 +134,7 @@ static void run(String[] args) throws IOException {
if (statusBuckets > 0)
queryArgs.put("status_buckets", statusBuckets);
- // always block until results are ready.
+ // Always block until results are ready.
queryArgs.put("exec_mode", "blocking");
Job job = service.getJobs().create(query, queryArgs);
@@ -158,21 +159,41 @@ else if (output.equals("timeline"))
stream = job.getTimeline(outputArgs);
else assert(false);
- InputStreamReader reader = new InputStreamReader(stream);
- OutputStreamWriter writer = new OutputStreamWriter(System.out);
-
- int size = 1024;
- char[] buffer = new char[size];
- while (true) {
- int count = reader.read(buffer);
- if (count == -1) break;
- writer.write(buffer, 0, count);
+ boolean rawData = true;
+ if (command.opts.containsKey("raw")) {
+ int tmp = (Integer)command.opts.get("raw");
+ if (tmp == 0 ) rawData = false;
}
- writer.write("\n");
- writer.close();
- reader.close();
-
+ if (!rawData) {
+ HashMap map;
+ try {
+ ResultsReaderXml resultsReader = new ResultsReaderXml(stream);
+ while ((map = resultsReader.getNextEvent()) != null) {
+ System.out.println("EVENT:********");
+ System.out.println(" " + map);
+ }
+ resultsReader.close();
+ } catch (IOException e) {
+ System.out.println("I/O exception: " + e);
+ }
+ }
+ else {
+ InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
+ OutputStreamWriter writer = new OutputStreamWriter(System.out);
+
+ int size = 1024;
+ char[] buffer = new char[size];
+ while (true) {
+ int count = reader.read(buffer);
+ if (count == -1) break;
+ writer.write(buffer, 0, count);
+ }
+
+ writer.write("\n");
+ writer.close();
+ reader.close();
+ }
job.cancel();
}
}
diff --git a/examples/search_oneshot/com/splunk/sdk/search_oneshot/Program.java b/examples/src/main/java/com/splunk/examples/search_oneshot/Program.java
similarity index 59%
rename from examples/search_oneshot/com/splunk/sdk/search_oneshot/Program.java
rename to examples/src/main/java/com/splunk/examples/search_oneshot/Program.java
index 3cb5278c..1042ba07 100644
--- a/examples/search_oneshot/com/splunk/sdk/search_oneshot/Program.java
+++ b/examples/src/main/java/com/splunk/examples/search_oneshot/Program.java
@@ -14,25 +14,30 @@
* under the License.
*/
-package com.splunk.sdk.search_oneshot;
+package com.splunk.examples.search_oneshot;
import com.splunk.Args;
import com.splunk.HttpException;
-import com.splunk.sdk.Command;
+import com.splunk.ResultsReaderXml;
import com.splunk.Service;
+import com.splunk.Command;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.util.HashMap;
// Note: not all search parameters are exposed to the CLI for this example.
public class Program {
- static String earliestTime = "Search earliest time";
+ static String earliestTimeText = "Search earliest time";
static String fieldListText =
"A comma-separated list of the fields to return";
- static String latestTime = "Search latest time";
+ static String latestTimeText = "Search latest time";
+ static String outputModeText =
+ "Search output format {csv, raw, json, xml} (default: xml)";
+ static String rawText = "Set to 1 if raw events are displayed";
static String statusBucketsText =
"Number of status buckets to use for search (default: 0)";
@@ -48,9 +53,11 @@ public static void main(String[] args) {
static void run(String[] args) throws IOException {
Command command = Command.splunk("search");
- command.addRule("earliest_time", String.class, earliestTime);
+ command.addRule("earliest_time", String.class, earliestTimeText);
command.addRule("field_list", String.class, fieldListText);
- command.addRule("latest_time", String.class, latestTime);
+ command.addRule("latest_time", String.class, latestTimeText);
+ command.addRule("output_mode", String.class, outputModeText);
+ command.addRule("raw", Integer.class, rawText);
command.addRule("status_buckets", Integer.class, statusBucketsText);
command.parse(args);
@@ -68,12 +75,16 @@ static void run(String[] args) throws IOException {
String latestTime = null;
if (command.opts.containsKey("latest_time"))
- earliestTime = (String)command.opts.get("latest_time");
+ latestTime = (String)command.opts.get("latest_time");
int statusBuckets = 0;
if (command.opts.containsKey("status_buckets"))
statusBuckets = (Integer)command.opts.get("status_buckets");
+ String outputMode = "xml";
+ if (command.opts.containsKey("output_mode"))
+ outputMode = (String)command.opts.get("output_mode");
+
Service service = Service.connect(command.opts);
// Check the syntax of the query.
@@ -96,24 +107,46 @@ static void run(String[] args) throws IOException {
queryArgs.put("latest_time", latestTime);
if (statusBuckets > 0)
queryArgs.put("status_buckets", statusBuckets);
+ queryArgs.put("output_mode", outputMode);
- // execute the oneshot query, which returns the stream (i.e. there is
+ // Execute the oneshot query, which returns the stream (i.e. there is
// no search job created, just a one time search)
- InputStream stream = service.oneshot(query, queryArgs);
-
- InputStreamReader reader = new InputStreamReader(stream);
- OutputStreamWriter writer = new OutputStreamWriter(System.out);
+ InputStream stream = service.oneshotSearch(query, queryArgs);
- int size = 1024;
- char[] buffer = new char[size];
- while (true) {
- int count = reader.read(buffer);
- if (count == -1) break;
- writer.write(buffer, 0, count);
+ boolean rawData = true;
+ if (command.opts.containsKey("raw")) {
+ int tmp = (Integer)command.opts.get("raw");
+ if (tmp == 0 ) rawData = false;
}
- writer.write("\n");
- writer.close();
- reader.close();
+ if (!rawData) {
+ HashMap map;
+ try {
+ ResultsReaderXml resultsReader = new ResultsReaderXml(stream);
+ while ((map = resultsReader.getNextEvent()) != null) {
+ System.out.println("EVENT:********");
+ System.out.println(" " + map);
+ }
+ resultsReader.close();
+ } catch (IOException e) {
+ System.out.println("I/O exception: " + e);
+ }
+ }
+ else {
+ InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
+ OutputStreamWriter writer = new OutputStreamWriter(System.out);
+
+ int size = 1024;
+ char[] buffer = new char[size];
+ while (true) {
+ int count = reader.read(buffer);
+ if (count == -1) break;
+ writer.write(buffer, 0, count);
+ }
+
+ writer.write("\n");
+ writer.close();
+ reader.close();
+ }
}
}
diff --git a/examples/search_realtime/com/splunk/sdk/search_realtime/Program.java b/examples/src/main/java/com/splunk/examples/search_realtime/Program.java
similarity index 73%
rename from examples/search_realtime/com/splunk/sdk/search_realtime/Program.java
rename to examples/src/main/java/com/splunk/examples/search_realtime/Program.java
index d2107fab..f2372b53 100644
--- a/examples/search_realtime/com/splunk/sdk/search_realtime/Program.java
+++ b/examples/src/main/java/com/splunk/examples/search_realtime/Program.java
@@ -14,19 +14,16 @@
* under the License.
*/
-package com.splunk.sdk.search_realtime;
+package com.splunk.examples.search_realtime;
-import com.splunk.Args;
-import com.splunk.HttpException;
-import com.splunk.Job;
-import com.splunk.sdk.Command;
-import com.splunk.Service;
+import com.splunk.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
+import java.util.HashMap;
// Note: not all search parameters are exposed to the CLI for this example.
public class Program {
@@ -34,18 +31,21 @@ public class Program {
"events", "results", "preview", "searchlog", "summary", "timeline"
};
- static String earliestTime =
+ static String earliestTimeText =
"Search earliest time (default: 'rt-5m')";
static String fieldListText =
"A comma-separated list of the fields to return";
- static String latestTime =
+ static String latestTimeText =
"Search latest time (default: 'rt' (i.e. now))";
static String offset =
- "The first result (inclusive) from which to begin returning data. (default: 0)";
+ "The first result (inclusive) from which to begin returning data. " +
+ "(default: 0)";
static String outputText =
- "Which search results to output {events, results, preview, searchlog, summary, timeline} (default: preview)";
+ "Which search results to output {events, results, preview, searchlog," +
+ " summary, timeline} (default: preview)";
static String outputModeText =
"Search output format {csv, raw, json, xml} (default: xml)";
+ static String rawText = "Set to 1 if raw events are displayed";
static String resultsCount =
"The maximum number of results to return (default: 100)";
static String statusBucketsText =
@@ -64,12 +64,13 @@ public static void main(String[] args) {
static void run(String[] args) throws IOException {
Command command = Command.splunk("search");
command.addRule("count", Integer.class, resultsCount);
- command.addRule("earliest_time", String.class, earliestTime);
+ command.addRule("earliest_time", String.class, earliestTimeText);
command.addRule("field_list", String.class, fieldListText);
- command.addRule("latest_time", String.class, latestTime);
+ command.addRule("latest_time", String.class, latestTimeText);
command.addRule("offset", Integer.class, offset);
command.addRule("output", String.class, outputText);
command.addRule("output_mode", String.class, outputModeText);
+ command.addRule("raw", Integer.class, rawText);
command.addRule("status_buckets", Integer.class, statusBucketsText);
command.parse(args);
@@ -91,7 +92,7 @@ static void run(String[] args) throws IOException {
String latestTime = "rt";
if (command.opts.containsKey("latest_time"))
- earliestTime = (String)command.opts.get("latest_time");
+ latestTime = (String)command.opts.get("latest_time");
int offset = 0;
if (command.opts.containsKey("offset"))
@@ -131,13 +132,21 @@ static void run(String[] args) throws IOException {
if (statusBuckets > 0)
queryArgs.put("status_buckets", statusBuckets);
- // always set real time search mode
+ // Always set real time search mode
queryArgs.put("search_mode", "realtime");
queryArgs.put("earliest_time", earliestTime);
queryArgs.put("latest_time", latestTime);
Job job = service.getJobs().create(query, queryArgs);
+ while (!job.isReady()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // You shouldn't ever get here.
+ }
+ }
+
InputStream stream = null;
Args outputArgs = new Args();
@@ -159,21 +168,41 @@ else if (output.equals("timeline"))
stream = job.getTimeline(outputArgs);
else assert(false);
- InputStreamReader reader = new InputStreamReader(stream);
- OutputStreamWriter writer = new OutputStreamWriter(System.out);
-
- int size = 1024;
- char[] buffer = new char[size];
- while (true) {
- int count = reader.read(buffer);
- if (count == -1) break;
- writer.write(buffer, 0, count);
+ boolean rawData = false;
+ if (command.opts.containsKey("raw")) {
+ int tmp = (Integer)command.opts.get("raw");
+ if (tmp == 0 ) rawData = false;
}
- writer.write("\n");
- writer.close();
- reader.close();
-
+ if (!rawData) {
+ HashMap map;
+ try {
+ ResultsReaderXml resultsReader = new ResultsReaderXml(stream);
+ while ((map = resultsReader.getNextEvent()) != null) {
+ System.out.println("EVENT:********");
+ System.out.println(" " + map);
+ }
+ resultsReader.close();
+ } catch (IOException e) {
+ System.out.println("I/O exception: " + e);
+ }
+ }
+ else {
+ InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
+ OutputStreamWriter writer = new OutputStreamWriter(System.out);
+
+ int size = 1024;
+ char[] buffer = new char[size];
+ while (true) {
+ int count = reader.read(buffer);
+ if (count == -1) break;
+ writer.write(buffer, 0, count);
+ }
+
+ writer.write("\n");
+ writer.close();
+ reader.close();
+ }
job.cancel();
}
}
diff --git a/examples/src/main/java/com/splunk/examples/search_saved/Program.java b/examples/src/main/java/com/splunk/examples/search_saved/Program.java
new file mode 100644
index 00000000..be48ba02
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/search_saved/Program.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011 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.examples.search_saved;
+
+import com.splunk.*;
+
+public class Program {
+
+ static String countString = "How many saved searches to return";
+ static String offsetString = "The offset into the collection";
+
+ private static void list(Service service, Args window) {
+
+ EntityCollection searches;
+
+ if (window == null)
+ searches = service.getSavedSearches();
+ else
+ searches = service.getSavedSearches(window);
+
+ for (SavedSearch entity: searches.values()) {
+ System.out.println(
+ entity.getTitle() + "\n" +
+ " (" + entity.getSearch()+ ")");
+ }
+ }
+
+ public static void main(String[] args) {
+ Command command = Command.splunk("search saved").parse(args);
+ command.addRule("count", String.class, countString);
+ command.addRule("offset", String.class, offsetString);
+ Service service = Service.connect(command.opts);
+
+ if (command.args.length == 0) {
+ list(service, null);
+ return;
+ }
+
+ Args window = new Args();
+ for (String value: args) {
+ String [] parts = value.split("=");
+ if (parts.length != 2) {
+ Command.error("Arguments are of the form: name=value");
+ }
+ if (!parts[0].equals("count") && !parts[0].equals("offset")) {
+ Command.error("Unknown key: " + parts[0]);
+ }
+ window.put(parts[0], parts[1]);
+ }
+
+ list(service, window);
+ }
+}
diff --git a/examples/src/main/java/com/splunk/examples/search_simple/Program.java b/examples/src/main/java/com/splunk/examples/search_simple/Program.java
new file mode 100644
index 00000000..9f279ddc
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/search_simple/Program.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2011 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.examples.search_simple;
+
+import com.splunk.Args;
+import com.splunk.HttpException;
+import com.splunk.Service;
+import com.splunk.Command;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+// Note: not all search parameters are exposed to the CLI for this example.
+public class Program {
+
+ public static void main(String[] args) {
+ try {
+ run(args);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static void run(String[] args) throws IOException {
+ Command command = Command.splunk("search");
+ command.parse(args);
+
+ if (command.args.length != 1)
+ Command.error("Search expression required");
+ String query = command.args[0];
+
+ Service service = Service.connect(command.opts);
+
+ // Check the syntax of the query.
+ try {
+ Args parseArgs = new Args("parse_only", true);
+ service.parse(query, parseArgs);
+ }
+ catch (HttpException e) {
+ String detail = e.getDetail();
+ Command.error("query '%s' is invalid: %s", query, detail);
+ }
+
+ // This is the simplest form of searching splunk. Note that additional
+ // arguments are allowed, but they are not shown in this example.
+ InputStream stream = service.oneshotSearch(query);
+
+ InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
+ try {
+ OutputStreamWriter writer = new OutputStreamWriter(System.out);
+ try {
+ int size = 1024;
+ char[] buffer = new char[size];
+ while (true) {
+ int count = reader.read(buffer);
+ if (count == -1) break;
+ writer.write(buffer, 0, count);
+ }
+
+ writer.write("\n");
+ }
+ finally {
+ writer.close();
+ }
+ }
+ finally {
+ reader.close();
+ }
+ }
+}
diff --git a/examples/spurl/com/splunk/sdk/spurl/Program.java b/examples/src/main/java/com/splunk/examples/spurl/Program.java
similarity index 92%
rename from examples/spurl/com/splunk/sdk/spurl/Program.java
rename to examples/src/main/java/com/splunk/examples/spurl/Program.java
index c00f6845..8c1707b3 100644
--- a/examples/spurl/com/splunk/sdk/spurl/Program.java
+++ b/examples/src/main/java/com/splunk/examples/spurl/Program.java
@@ -14,11 +14,11 @@
* under the License.
*/
-package com.splunk.sdk.spurl;
+package com.splunk.examples.spurl;
import com.splunk.Service;
import com.splunk.ResponseMessage;
-import com.splunk.sdk.Command;
+import com.splunk.Command;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -47,7 +47,7 @@ static void run(String[] args) throws IOException {
if (status != 200) return;
BufferedReader reader = new BufferedReader(
- new InputStreamReader(response.getContent()));
+ new InputStreamReader(response.getContent(), "UTF-8"));
while (true) {
String line = reader.readLine();
if (line == null) break;
diff --git a/examples/src/main/java/com/splunk/examples/ssl_protocols/Program.java b/examples/src/main/java/com/splunk/examples/ssl_protocols/Program.java
new file mode 100644
index 00000000..a6352054
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/ssl_protocols/Program.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2015 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.
+ */
+
+/**
+ * This example will demonstrate how to use a specific SSL/TLS
+ * protocol to connect to Splunk.
+ * Additionally, there's a small code sample showing how to
+ * use a custom SSLSocketFactory to connect to Splunk.
+ */
+
+package com.splunk.examples.ssl_protocols;
+
+import com.splunk.Command;
+import com.splunk.SSLSecurityProtocol;
+import com.splunk.Service;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+
+
+public class Program {
+
+ public static Integer getJavaVersion() {
+ String ver = System.getProperty("java.version");
+ return Integer.parseInt(ver.substring(2, 3));
+ }
+
+ public static void main(String[] args) {
+ Command command = Command.splunk("info").parse(args);
+
+ int version = getJavaVersion();
+ System.out.println("Your Java version is: " + version);
+
+ // At this point, the default protocol is SSLv3.
+ // Possible values are TLSv1.2, TLSv1.1, TLSv1 & SSLv3
+ // These are defined by the SSLSecurityProtocol enum
+ // Java 8 disables SSLv3 by default
+ System.out.println("Now trying to connect to Splunk using SSLv3");
+ try {
+ Service.setSslSecurityProtocol(SSLSecurityProtocol.SSLv3);
+ Service serviceSSLv3 = Service.connect(command.opts);
+ serviceSSLv3.login();
+ System.out.println("\t Success!");
+ } catch (RuntimeException e) {
+ System.out.println("\t Failure! ");
+ }
+
+ // TLSv1 is available by default in every modern version of Java
+ System.out.println("Now trying to connect to Splunk using TLSv1");
+ try {
+ Service.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1);
+ Service serviceTLSv1 = Service.connect(command.opts);
+ serviceTLSv1.login();
+ System.out.println("\t Success!");
+ } catch (RuntimeException e) {
+ System.out.println("\t Failure! ");
+ }
+
+
+ // TLSv1.1 is available by default in Java 7 and up
+ System.out.println("Now trying to connect to Splunk using TLSv1.1");
+ try {
+ Service.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_1);
+ Service serviceTLSv1_1 = Service.connect(command.opts);
+ serviceTLSv1_1.login();
+ System.out.println("\t Success!");
+ } catch (RuntimeException e) {
+ System.out.println("\t Failure! ");
+ }
+
+ // TLSv1.2 is available by default in Java 7 and up
+ System.out.println("Now trying to connect to Splunk using TLSv1.2");
+ try {
+ Service.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
+ Service serviceTLSv1_2 = Service.connect(command.opts);
+ serviceTLSv1_2.login();
+ System.out.println("\t Success!");
+ } catch (RuntimeException e) {
+ System.out.println("\t Failure! ");
+ }
+
+ // You can also specify your own SSLSocketFactory, in this case any version of SSL
+ System.out.println("Now trying to connect to Splunk using a custom SSL only SSLSocketFactory");
+ try {
+ // Create an SSLSocketFactory configured to use SSL only
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ TrustManager[] byPassTrustManagers = new TrustManager[]{
+ new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] chain, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] chain, String authType) {
+ }
+ }
+ };
+ sslContext.init(null, byPassTrustManagers, new SecureRandom());
+ SSLSocketFactory SSLOnlySSLFactory = sslContext.getSocketFactory();
+ Service.setSSLSocketFactory(SSLOnlySSLFactory);
+
+ Service serviceCustomSSLFactory = Service.connect(command.opts);
+ serviceCustomSSLFactory.login();
+ System.out.println("\t Success!");
+ } catch (Exception e) {
+ System.out.println("\t Failure!");
+ }
+
+ // You can also specify your own SSLSocketFactory, in this case any version of TLS
+ System.out.println("Now trying to connect to Splunk using a custom TLS only SSLSocketFactory");
+ try {
+ // Create an SSLSocketFactory configured to use TLS only
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ TrustManager[] byPassTrustManagers = new TrustManager[]{
+ new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] chain, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] chain, String authType) {
+ }
+ }
+ };
+ sslContext.init(null, byPassTrustManagers, new SecureRandom());
+ SSLSocketFactory TLSOnlySSLFactory = sslContext.getSocketFactory();
+ Service.setSSLSocketFactory(TLSOnlySSLFactory);
+
+ Service serviceCustomSSLFactory = Service.connect(command.opts);
+ serviceCustomSSLFactory.login();
+ System.out.println("\t Success!");
+ } catch (Exception e) {
+ System.out.println("\t Failure!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/tail/com/splunk/sdk/tail/Program.java b/examples/src/main/java/com/splunk/examples/tail/Program.java
similarity index 76%
rename from examples/tail/com/splunk/sdk/tail/Program.java
rename to examples/src/main/java/com/splunk/examples/tail/Program.java
index f69252d7..6f2b7543 100644
--- a/examples/tail/com/splunk/sdk/tail/Program.java
+++ b/examples/src/main/java/com/splunk/examples/tail/Program.java
@@ -14,10 +14,9 @@
* under the License.
*/
-package com.splunk.sdk.tail;
+package com.splunk.examples.tail;
import com.splunk.*;
-import com.splunk.sdk.Command;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -45,7 +44,7 @@ public static void main(String[] args) {
static void run(String[] argsIn) throws Exception {
Command command = Command.splunk("tail");
- command.addRule("format", Integer.class, outputModeText);
+ command.addRule("format", String.class, outputModeText);
command.parse(argsIn);
if (command.args.length != 1)
@@ -55,21 +54,21 @@ static void run(String[] argsIn) throws Exception {
Service service = Service.connect(command.opts);
String outputMode = "csv";
- if (command.opts.containsKey("output_mode"))
- outputMode = (String)command.opts.get("output_mode");
+ if (command.opts.containsKey("format"))
+ outputMode = (String)command.opts.get("format");
Args args = new Args();
// search args
- args.put("timeout", "60"); // don't keep search around
- args.put("output_mode", outputMode); // output in specific format
- args.put("earliest_time", "rt"); // realtime
- args.put("latest_time", "rt"); // realtime
- args.put("search_mode", "realtime"); // realtime
+ args.put("timeout", "60"); // Don't keep search around
+ args.put("output_mode", outputMode); // Output in specific format
+ args.put("earliest_time", "rt"); // Realtime
+ args.put("latest_time", "rt"); // Realtime
+ args.put("search_mode", "realtime"); // Realtime
InputStream is = service.export(query, args);
- // use UTF8 sensitive reader/writers
- InputStreamReader reader = new InputStreamReader(is, "UTF8");
+ // Use UTF8 sensitive reader/writers
+ InputStreamReader reader = new InputStreamReader(is, "UTF-8");
OutputStreamWriter writer = new OutputStreamWriter(System.out);
int size = 1024;
diff --git a/examples/src/main/java/com/splunk/examples/testupdate/Program.java b/examples/src/main/java/com/splunk/examples/testupdate/Program.java
new file mode 100644
index 00000000..127b3746
--- /dev/null
+++ b/examples/src/main/java/com/splunk/examples/testupdate/Program.java
@@ -0,0 +1,11 @@
+package com.splunk.examples.testupdate;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: fross
+ * Date: 11/4/13
+ * Time: 1:56 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Program {
+}
diff --git a/examples/tail/tail.iml b/examples/tail/tail.iml
deleted file mode 100644
index be81447e..00000000
--- a/examples/tail/tail.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/launchers/README.md b/launchers/README.md
new file mode 100644
index 00000000..a13675d6
--- /dev/null
+++ b/launchers/README.md
@@ -0,0 +1,85 @@
+# Modular input launchers for the Splunk Enterprise SDK for Java
+
+Splunk Enterprise cannot launch Java programs as modular inputs directly. Instead, we need to provide a few small programs to launch a JVM and run a program. Since modular inputs written in Java need to work across all Splunk variants, including the universal forwarder, the launchers cannot rely on Python or anything else in the underlying system. Instead, we provide a set of C programs compiled for each of Linux, MacOS X, and Windows.
+
+The programs assume the following layout in an app: a jars/ directory containing a launchable jar containing the modular input, and a configuration file with a .ini suffix of the same base name that contains options for what JVM to launch and what options to pass to it. Then platform specific bin directories contain the launcher programs, named the base name of the target jar. For for a jar named myinput.jar, the layout would be
+
+myapp/
+ jars/
+ myinput.jar
+ myinput.ini
+ linux_x86/
+ myinput
+ linux_x86_64/
+ myinput
+ darwin_x86_64/
+ myinput
+ windows_x86/
+ myinput.exe
+ windows_x86_64/
+ myinput.exe
+
+The configuration file should have the form
+
+JAVA_HOME=/path/to/jre
+JAVA_OPTS=options to pass to JVM
+
+The keys are case insensitive, and leading whitespace and whitespace around the equals sign is ignored.
+
+The POSIX launchers use the exec system call to replace the launcher with a JVM with the proper arguments. The Windows launcher starts the JVM with a call to CreateProcess, forwards exit events, and monitors the JVM it launches for termination.
+
+Testing story:
+
+http://stackoverflow.com/questions/65820/unit-testing-c-code
+
+There are a lot of options.
+
+
+
+Windows:
+
+Use GetModuleFileName(NULL) to get current name and path of this executable.
+
+For Linux,
+
+ char *resolved_path = realpath("/proc/self/exe", NULL);
+ printf("%s\n", resolved_path);
+ free(resolved_path);
+
+/proc/pid/exe on Linux and /proc/pid/file on BSD are symlinks to the executable. Call readlink to resolve the symlink to get the path.
+
+On OS X, there are two ways:
+http://stackoverflow.com/questions/799679/programatically-retrieving-the-absolute-path-of-an-os-x-command-line-app/1024933#1024933
+libproc.h has proc_pidpath
+_NSGetExecutablePath in dyld
+
+#include
+#include
+#include
+#include
+#include
+
+int main (int argc, char* argv[])
+{
+ int ret;
+ pid_t pid;
+ char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
+
+ pid = getpid();
+ ret = proc_pidpath (pid, pathbuf, sizeof(pathbuf));
+ if ( ret <= 0 ) {
+ fprintf(stderr, "PID %d: proc_pidpath ();\n", pid);
+ fprintf(stderr, " %s\n", strerror(errno));
+ } else {
+ printf("proc %d: %s\n", pid, pathbuf);
+ }
+
+ return 0;
+}
+
+proc_pidpath looks like the way to go. I'll test it.
+
+To exec the program:
+
+ char* args[] = {"java", "-jar", "braindead.jar", NULL};
+ execvp("java", args);
diff --git a/launchers/shim-darwin.sh b/launchers/shim-darwin.sh
new file mode 100755
index 00000000..145f1e46
--- /dev/null
+++ b/launchers/shim-darwin.sh
@@ -0,0 +1,42 @@
+# Shim to run a modular input written in Java. The modular input
+# is assumed to be in the form of an executable jar. This shim
+# is in ${PLATFORM}/bin/${INPUTNAME}.sh of the app the modular
+# input is contained in, and the jar is assumed to be in
+# jars/${INPUTNAME}.jar in the app.
+#
+# If ${PLATFORM}/bin/customized.java.path exists, this script will
+# use java cmd defined in this file to start jvm, else default java
+# will be used.
+#
+# Extra arguments to the JVM (i.e., -Xms512M) can be put in
+# a file jars/${INPUTNAME}.vmopts and will be interpolated
+# into the command to run the JVM.
+SCRIPT="$0"
+
+cd `dirname "$SCRIPT"`
+SCRIPT=`basename "$SCRIPT"`
+
+while [ -L "$SCRIPT" ]; do
+ SCRIPT=`readlink "$SCRIPT"`
+ cd `dirname "$SCRIPT"`
+ SCRIPT=`basename "$SCRIPT"`
+done
+
+BASENAME=$(basename "$SCRIPT" .sh)
+JAR_DIR=`pwd -P`/../../jars
+CUSTOMIZED_JAVA_PATH_FILE=`pwd -P`/customized.java.path
+
+if [ -f $CUSTOMIZED_JAVA_PATH_FILE ]; then
+ JAVA_CMD=`cat $CUSTOMIZED_JAVA_PATH_FILE`
+else
+ JAVA_CMD="java"
+fi
+
+if [ -f $JAR_DIR/$BASENAME.vmopts ]; then
+ VMOPTS=`cat $JAR_DIR/$BASENAME.vmopts`
+else
+ VMOPTS=""
+fi
+
+exec $JAVA_CMD $VMOPTS -jar $JAR_DIR/$BASENAME.jar $@
+
diff --git a/launchers/shim-linux.sh b/launchers/shim-linux.sh
new file mode 100755
index 00000000..e0676451
--- /dev/null
+++ b/launchers/shim-linux.sh
@@ -0,0 +1,31 @@
+# Shim to run a modular input written in Java. The modular input
+# is assumed to be in the form of an executable jar. This shim
+# is in ${PLATFORM}/bin/${INPUTNAME}.sh of the app the modular
+# input is contained in, and the jar is assumed to be in
+# jars/${INPUTNAME}.jar in the app.
+#
+# If ${PLATFORM}/bin/customized.java.path exists, this script will
+# use java cmd defined in this file to start jvm, else default java
+# will be used.
+#
+# Extra arguments to the JVM (i.e., -Xms512M) can be put in
+# a file jars/${INPUTNAME}.vmopts and will be interpolated
+# into the command to run the JVM.
+SCRIPT=$(readlink -f "$0")
+BASENAME=$(basename "$SCRIPT" .sh)
+JAR_DIR=$(dirname "$SCRIPT")/../../jars
+CUSTOMIZED_JAVA_PATH_FILE=$(dirname "$SCRIPT")/customized.java.path
+
+if [ -f $CUSTOMIZED_JAVA_PATH_FILE ]; then
+ JAVA_CMD=`cat $CUSTOMIZED_JAVA_PATH_FILE`
+else
+ JAVA_CMD="java"
+fi
+
+if [ -f $JAR_DIR/$BASENAME.vmopts ]; then
+ VMOPTS=`cat $JAR_DIR/$BASENAME.vmopts`
+else
+ VMOPTS=""
+fi
+
+exec $JAVA_CMD $VMOPTS -jar $JAR_DIR/$BASENAME.jar $@
\ No newline at end of file
diff --git a/launchers/shim-windows_x86.exe b/launchers/shim-windows_x86.exe
new file mode 100755
index 00000000..3ec87105
Binary files /dev/null and b/launchers/shim-windows_x86.exe differ
diff --git a/launchers/shim-windows_x86_64.exe b/launchers/shim-windows_x86_64.exe
new file mode 100755
index 00000000..ffb1f4fc
Binary files /dev/null and b/launchers/shim-windows_x86_64.exe differ
diff --git a/launchers/shim/jars/shim.jar b/launchers/shim/jars/shim.jar
new file mode 100755
index 00000000..cc5440c1
Binary files /dev/null and b/launchers/shim/jars/shim.jar differ
diff --git a/launchers/shim/jars/shim.vmopts b/launchers/shim/jars/shim.vmopts
new file mode 100755
index 00000000..2b72e100
--- /dev/null
+++ b/launchers/shim/jars/shim.vmopts
@@ -0,0 +1 @@
+-Xms512M
\ No newline at end of file
diff --git a/launchers/shim/shim.sln b/launchers/shim/shim.sln
new file mode 100755
index 00000000..67987d0b
--- /dev/null
+++ b/launchers/shim/shim.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shim", "shim\shim.vcxproj", "{830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Debug|Win32.ActiveCfg = Debug|x64
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Debug|Win32.Build.0 = Debug|x64
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Debug|x64.ActiveCfg = Debug|x64
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Debug|x64.Build.0 = Debug|x64
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Release|Win32.ActiveCfg = Release|Win32
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Release|Win32.Build.0 = Release|Win32
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Release|x64.ActiveCfg = Release|x64
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/launchers/shim/shim.v11.suo b/launchers/shim/shim.v11.suo
new file mode 100755
index 00000000..d173cadb
Binary files /dev/null and b/launchers/shim/shim.v11.suo differ
diff --git a/launchers/shim/shim/ReadMe.txt b/launchers/shim/shim/ReadMe.txt
new file mode 100755
index 00000000..8672406b
--- /dev/null
+++ b/launchers/shim/shim/ReadMe.txt
@@ -0,0 +1,40 @@
+========================================================================
+ CONSOLE APPLICATION : shim Project Overview
+========================================================================
+
+AppWizard has created this shim application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your shim application.
+
+
+shim.vcxproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+shim.vcxproj.filters
+ This is the filters file for VC++ projects generated using an Application Wizard.
+ It contains information about the association between the files in your project
+ and the filters. This association is used in the IDE to show grouping of files with
+ similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+ "Source Files" filter).
+
+shim.cpp
+ This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named shim.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/launchers/shim/shim/shim.cpp b/launchers/shim/shim/shim.cpp
new file mode 100755
index 00000000..cbbf0778
--- /dev/null
+++ b/launchers/shim/shim/shim.cpp
@@ -0,0 +1,403 @@
+/*
+ * Copyright 2013 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.
+ */
+
+#include "stdafx.h"
+#include "shim.h"
+
+// Global variable used to let the Ctrl+C handler propogate Ctrl+C to the JVM.
+DWORD jvmPid = NULL;
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ HANDLE processHandles[2] = {NULL, NULL};
+ HANDLE &splunkdHandle = processHandles[0];
+ HANDLE &jvmHandle = processHandles[1];
+ HANDLE ghJob = NULL;
+ PTSTR customizedJavaCmd = NULL, jarPath = NULL, jvmOptions = NULL, jvmCommandLine = NULL;
+ DWORD waitOutcome;
+ DWORD returnCode = 0;
+
+ STARTUPINFO si;
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+
+ PROCESS_INFORMATION pi;
+ ZeroMemory(&pi, sizeof(pi));
+
+ SetConsoleCtrlHandler((PHANDLER_ROUTINE)killJvm, TRUE);
+ splunkdHandle = getSplunkdHandle();
+
+ if (NULL == splunkdHandle) {
+ // Couldn't get a handle to splunkd.
+ printErrorMessage(GetLastError());
+
+ returnCode = 1;
+ goto CLEAN_UP_AND_EXIT;
+ }
+
+ // create a job
+ ghJob = CreateJobObject(NULL, NULL);
+ if(ghJob == NULL) {
+ printErrorMessage(GetLastError());
+
+ returnCode = 1;
+ goto CLEAN_UP_AND_EXIT;
+ }else {
+ JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
+
+ // Configure all child processes associated with the job to terminate when the main process terminated
+ jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
+ if(0 == SetInformationJobObject(ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli))) {
+ printErrorMessage(GetLastError());
+
+ returnCode = 1;
+ goto CLEAN_UP_AND_EXIT;
+ }
+ }
+
+ customizedJavaCmd = getCustomizedJavaCmd();
+ jarPath = getPathToJar();
+ jvmOptions = readJvmOptions(jarPath);
+ jvmCommandLine = assembleJvmCommand(customizedJavaCmd, jarPath, jvmOptions, argc, argv);
+
+ if (!CreateProcess(NULL, jvmCommandLine, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) {
+ // Process creation failed.
+ printErrorMessage(GetLastError(), jvmCommandLine);
+
+ returnCode = 1;
+ goto CLEAN_UP_AND_EXIT;
+ }
+
+ // bind java process to this job
+ if(0 == AssignProcessToJobObject(ghJob, pi.hProcess)) {
+ printErrorMessage(GetLastError());
+
+ returnCode = 1;
+ goto CLEAN_UP_AND_EXIT;
+ }
+
+ CloseHandle(pi.hThread); // CreateProcess gives us a handle to the initial thread of the new process, which we don't need.
+ jvmHandle = pi.hProcess;
+ jvmPid = pi.dwProcessId;
+ waitOutcome = WaitForMultipleObjects(2, processHandles, FALSE, INFINITE);
+
+ if (waitOutcome == WAIT_OBJECT_0) {
+ // Splunkd has died
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
+
+ goto CLEAN_UP_AND_EXIT;
+ } else if (waitOutcome == WAIT_OBJECT_0 + 1) {
+ // JVM has died
+ if (!GetExitCodeProcess(jvmHandle, &returnCode)) {
+ printErrorMessage(GetLastError());
+ returnCode = 1;
+ }
+ goto CLEAN_UP_AND_EXIT;
+ } else {
+ // There was some other error
+ printErrorMessage(GetLastError());
+
+ returnCode = 1;
+ goto CLEAN_UP_AND_EXIT;
+ }
+
+CLEAN_UP_AND_EXIT:
+ if (NULL != jvmCommandLine) LocalFree(jvmCommandLine);
+ if (NULL != jvmOptions) LocalFree(jvmOptions);
+ if (NULL != jarPath) LocalFree(jarPath);
+ if (NULL != customizedJavaCmd) LocalFree(customizedJavaCmd);
+
+ if (NULL != splunkdHandle) CloseHandle(splunkdHandle);
+ if (NULL != jvmHandle) CloseHandle(jvmHandle);
+ if (NULL != ghJob) CloseHandle(ghJob);
+
+ return returnCode;
+}
+
+
+BOOL killJvm(DWORD interruptCode) {
+ if (jvmPid != NULL) {
+ GenerateConsoleCtrlEvent(interruptCode, jvmPid);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+void printErrorMessage(DWORD errorCode, ...) {
+ LPTSTR buffer;
+
+ va_list args = NULL;
+ va_start(args, errorCode);
+
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buffer, 0, &args);
+
+ fwprintf(stderr, TEXT("ERROR %s\r\n"), buffer);
+
+ LocalFree(buffer);
+}
+
+
+PTSTR readJvmOptions(PTSTR jarPath) {
+ size_t jarPathLen = _tcslen(jarPath);
+ // vmoptsPath is the same as jarPath, but ending with .vmopts instead of .jar. We allocate
+ // 3 additional TCHARs for the additional length of .vmopts, and 1 more TCHAR for a NULL
+ // terminator, so jarPathLen+4.
+ PTSTR vmoptsPath = (PTSTR)malloc(sizeof(TCHAR) * (jarPathLen + 4));
+ PTSTR suffixPtr = vmoptsPath;
+
+ _tcscpy_s(vmoptsPath, jarPathLen+1, jarPath);
+
+ suffixPtr = _tcsrchr(vmoptsPath, CHAR('.'));
+ if (suffixPtr == 0) {
+ SetLastError(ERROR_INVALID_DATA);
+ return NULL;
+ }
+
+ _tcscpy_s(suffixPtr, 8, TEXT(".vmopts"));
+
+ HANDLE vmoptsHandle = CreateFile(vmoptsPath, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (INVALID_HANDLE_VALUE == vmoptsHandle) {
+ if (ERROR_FILE_NOT_FOUND == GetLastError() || ERROR_PATH_NOT_FOUND == GetLastError()) {
+ // We can't return a literal because we will try to deallocate it later.
+ free(vmoptsPath);
+ vmoptsPath = (PTSTR)malloc(sizeof(TCHAR));
+ _tcscpy_s(vmoptsPath, 1, TEXT(""));
+ return vmoptsPath;
+ } else {
+ return NULL;
+ }
+ }
+
+ DWORD fileSize = GetFileSize(vmoptsHandle, NULL);
+ if (INVALID_FILE_SIZE == fileSize) {
+ return NULL;
+ }
+
+ DWORD nRead;
+ char* buffer = (char*)malloc((fileSize+1) * sizeof(char)); // +1 to give space for a NULL character.
+ if (!ReadFile(vmoptsHandle, buffer, fileSize, &nRead, NULL)) {
+ return NULL;
+ }
+ buffer[nRead] = NULL; // Ensure options are null terminated.
+
+ if (NULL != vmoptsHandle) CloseHandle(vmoptsHandle);
+
+#ifdef _UNICODE
+ // Calculate how much space is needed.
+ DWORD nWchars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buffer, nRead, NULL, 0);
+ wchar_t *vmopts = (wchar_t*)malloc(sizeof(wchar_t) * (nWchars+1));
+ if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buffer, nRead, vmopts, nWchars)) {
+ return NULL;
+ }
+ vmopts[nWchars] = NULL;
+ return vmopts;
+#else
+ return buffer;
+#endif
+}
+
+
+PTSTR assembleJvmCommand(PTSTR customizedJavaCmd, PTSTR jarPath, PTSTR jvmOptions, int argc, _TCHAR* argv[]) {
+ PTSTR buffer, index;
+ size_t len;
+ int i;
+
+ len = 0;
+ for (i = 1; i < argc; i++) {
+ len += _tcslen(argv[i]) + 1; // The +1 accounts for a space to separate the arguments
+ }
+
+ // 9 + max(command) = number of characters for java cmd and -jar sections; +1 at the end is for the null terminator.
+ buffer = (PTSTR)malloc((9 + max(_tcslen(customizedJavaCmd), 4) + _tcslen(jarPath) + _tcslen(jvmOptions) + len + 1) * sizeof(TCHAR));
+ index = buffer;
+
+#define APPEND_TCS(literal) { \
+ _tcscpy_s(index, _tcslen(literal)+1, literal); \
+ index += _tcslen(literal); \
+}
+ if (NULL != customizedJavaCmd && 0 != _tcslen(customizedJavaCmd)) {
+ APPEND_TCS(customizedJavaCmd);
+ APPEND_TCS(TEXT(" "));
+ } else {
+ APPEND_TCS(TEXT("java "));
+ }
+ APPEND_TCS(jvmOptions);
+ APPEND_TCS(TEXT(" -jar \""));
+ APPEND_TCS(jarPath);
+ APPEND_TCS(TEXT("\""));
+
+ for (i = 1; i < argc; i++) {
+ APPEND_TCS(TEXT(" "));
+ APPEND_TCS(argv[i]);
+ }
+
+#undef APPEND_TCS
+
+ return buffer;
+}
+
+
+HANDLE getSplunkdHandle() {
+ const TCHAR* SPLUNKD_HANDLE_ENVVAR = TEXT("SPLUNKD_PROCESSID");
+
+ size_t bufferSize;
+ TCHAR* pidBuffer;
+ TCHAR* stopString;
+
+ DWORD splunkdPid;
+
+ // Find how large a buffer we need.
+ _tgetenv_s(&bufferSize, NULL, 0, SPLUNKD_HANDLE_ENVVAR);
+ if (bufferSize == 0) {
+ SetLastError(ERROR_ENVVAR_NOT_FOUND);
+ return NULL;
+ }
+
+ pidBuffer = (PTSTR)malloc(bufferSize * sizeof(TCHAR));
+ if (_tgetenv_s(&bufferSize, pidBuffer, bufferSize, SPLUNKD_HANDLE_ENVVAR)) {
+ return NULL; // There was an error in getting the environment variable.
+ }
+ splunkdPid = _tcstoul(pidBuffer, &stopString, 10);
+
+ if (*stopString != NULL || splunkdPid == 0) {
+ // We haven't parsed the whole environment variable as a number.
+ SetLastError(ERROR_BAD_ENVIRONMENT);
+ return NULL;
+ }
+
+ free(pidBuffer);
+
+ return OpenProcess(SYNCHRONIZE, FALSE, splunkdPid);
+}
+
+
+PTSTR getPathToJar() {
+ PTSTR thisPath, endPtr, baseName;
+ PCTSTR jarPathFragment = TEXT("\\jars\\");
+ const DWORD jarPathFragmentLen = 7;
+ PCTSTR jarSuffix = TEXT(".jar");
+ const DWORD jarSuffixLen = 5;
+ const size_t N = 1024;
+ size_t baseNameLen;
+
+ thisPath = (PTSTR)malloc(N*sizeof(TCHAR));
+ if (N == GetModuleFileName(NULL, thisPath, N) && ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
+ return NULL;
+ }
+
+ // The following code removes the last two path segments before the executable name in the buffer,
+ // puts a \jars\ on the path, then shifts the base name of the executable over and adds .jar to it.
+ // Graphically, with 0 representing null terminators, the steps are:
+ //
+ // 1. $SPLUNK_HOME$\etc\apps\myapp\windows_x86_64\bin\myinput.exe0
+ // 2. $SPLUNK_HOME$\etc\apps\myapp\jars\0 myinput.exe0
+ // 3. $SPLUNK_HOME$\etc\apps\myapp\jars\myinput0
+ // 4. $SPLUNK_HOME$\etc\apps\myapp\jars\myinput.jar0
+
+ // Find 'myinput.exe', just after the last \.
+ endPtr = _tcsrchr(thisPath, '\\');
+ baseName = endPtr+1; // This is 'myinput.exe'
+ *endPtr = NULL; // NULL terminate the string before this point so we can strrchar to get the next \.
+ endPtr = _tcsrchr(baseName, '.'); // Find .exe, and NULL terminate the base name.
+ *endPtr = NULL;
+
+ // Take two directory levels off this path.
+ endPtr = _tcsrchr(thisPath, '\\');
+ *endPtr = NULL;
+ endPtr = _tcsrchr(thisPath, '\\');
+
+ if ((size_t)(baseName-endPtr) < _tcslen(TEXT("\\jars\\"))) {
+ return NULL; // Not enough space to copy the path fragment in without clobbering the jar name.
+ }
+
+ // Instead of NULL terminating, we copy \jars\ over top and advance to the end of it.
+ _tcscpy_s(endPtr, jarPathFragmentLen, jarPathFragment);
+ endPtr += jarPathFragmentLen - 1;
+ // Now shift the base name over.
+ baseNameLen = _tcslen(baseName) + 1;
+ // Advance endPtr and add .jar to it.
+ memmove_s(endPtr, baseNameLen*sizeof(TCHAR), baseName, baseNameLen*sizeof(TCHAR));
+ endPtr += baseNameLen - 1;
+ _tcscpy_s(endPtr, jarSuffixLen, jarSuffix);
+
+ return thisPath;
+}
+
+PTSTR getCustomizedJavaCmd() {
+ PTSTR javaHomePath, endPtr;
+ PCTSTR javaHomeFragment = TEXT("\\customized.java.path");
+ const DWORD javaHomeFragmentLen = 22;
+ const size_t N = 1024;
+
+ javaHomePath = (PTSTR)malloc(N*sizeof(TCHAR));
+ if (N == GetModuleFileName(NULL, javaHomePath, N) && ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
+ return NULL;
+ }
+
+ // thisPath is: $SPLUNK_HOME$\etc\apps\myapp\windows_x86_64\bin\myinput.exe0
+ // Take three directory levels off this path.
+ endPtr = _tcsrchr(javaHomePath, '\\');
+ _tcscpy_s(endPtr, javaHomeFragmentLen, javaHomeFragment);
+ endPtr += javaHomeFragmentLen;
+ *endPtr = NULL;
+
+ HANDLE javaHomeHandle = CreateFile(javaHomePath, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (INVALID_HANDLE_VALUE == javaHomeHandle) {
+ if (ERROR_FILE_NOT_FOUND == GetLastError() || ERROR_PATH_NOT_FOUND == GetLastError()) {
+ // We can't return a literal because we will try to deallocate it later.
+ free(javaHomePath);
+ javaHomePath = (PTSTR)malloc(sizeof(TCHAR));
+ _tcscpy_s(javaHomePath, 1, TEXT(""));
+ return javaHomePath;
+ } else {
+ return NULL;
+ }
+ }
+
+ DWORD fileSize = GetFileSize(javaHomeHandle, NULL);
+ if (INVALID_FILE_SIZE == fileSize) {
+ return NULL;
+ }
+
+ DWORD nRead;
+ char* buffer = (char*)malloc((fileSize+1) * sizeof(char)); // +1 to give space for a NULL character.
+ if (!ReadFile(javaHomeHandle, buffer, fileSize, &nRead, NULL)) {
+ return NULL;
+ }
+ buffer[nRead] = NULL; // Ensure options are null terminated.
+
+ if (NULL != javaHomeHandle) CloseHandle(javaHomeHandle);
+
+#ifdef _UNICODE
+ // Calculate how much space is needed.
+ DWORD nWchars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buffer, nRead, NULL, 0);
+ wchar_t *javaHome = (wchar_t*)malloc(sizeof(wchar_t) * (nWchars+1));
+ if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buffer, nRead, javaHome, nWchars)) {
+ return NULL;
+ }
+ javaHome[nWchars] = NULL;
+ return javaHome;
+#else
+ return buffer;
+#endif
+}
diff --git a/launchers/shim/shim/shim.h b/launchers/shim/shim/shim.h
new file mode 100755
index 00000000..7c86df56
--- /dev/null
+++ b/launchers/shim/shim/shim.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2013 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.
+ */
+
+/**
+ * shim - Windows launcher for Splunk modular inputs written in Java.
+ *
+ * shim is provided as both 32-bit and 64-bit binaries. If you are setting up a
+ * modular input written in Java in your app, you should make it into an executable
+ * jar, and put it in a jars/ directory in your app. The jar should be named the
+ * with the same name as the modular input kind defined in Splunk. That is, if your
+ * stanza in README/inputs.conf.spec that defines the modular input kind is called
+ * 'myinput', then the jar should be in jars/myinput.jar. You can create a UTF-8 encoded
+ * text file in jars/myinput.vmopts that contains options to pass to java when creating
+ * the virtual machine (i.e., -Xms512M -agent something.jar).
+ *
+ * Then place the 32-bit binary of shim in windows_x86/bin/myinput.exe and the 64-bit
+ * binary in windows_x86_64/bin/myinput.exe (changing 'myinput' to the name of your modular
+ * input kind). Splunk will launch them and they in turn will look for the jar,
+ * launch it, and handle all the control signals from Splunk.
+ *
+ * Once shim starts and executes the JVM, it waits for Ctrl+C from Splunk or for splunkd
+ * to die. If either of these events occurs, it sends Ctrl+C to the JVM, waits for it
+ * to exit, and exits itself. If the JVM exits, the shim exits immediately thereafter.
+ */
+
+
+#ifndef __SHIM_H__
+#define __SHIM_H__
+
+#include
+
+/**
+ * Returns a HANDLE referring to splunkd's process, or NULL if it could
+ * not find such a handle. Use GetLastError to find the error in that case.
+ *
+ * When splunkd starts a modular input script, it sets its pid as the value of
+ * an environment variable SPLUNKD_PROCESSID.
+ */
+HANDLE getSplunkdHandle();
+
+
+/**
+ * Return a PTSTR with the path to the Java jar, or NULL if no path could be constructed.
+ *
+ * The jar is taken to be at ../../jars/{name}.jar from the location of the current executable,
+ * if the name of the current executable is {name}.exe.
+ */
+PTSTR getPathToJar();
+
+
+/**
+ * Returns the contents of a file with the same base name as the Jar referred to in jarPath,
+ * but with the suffix .vmopts (so for path\to\myinput.jar, reads path\to\myinputs.vmptops).
+ *
+ * This function is meant to read the options for the JVM (i.e., -Xms512M) so they can be
+ * added to the command line. If there is an error that prevents reading the file (the jar path
+ * does not end in .jar, or it cannot be read), readJvmOptions returns NULL and sets an error
+ * code retrievable with GetLastError. If the file does not exist, readJvmOptions returns an
+ * empty string.
+ */
+PTSTR readJvmOptions(PTSTR pathToJar);
+
+/**
+ * get the customized java command
+ */
+PTSTR getCustomizedJavaCmd();
+
+/**
+ * Construct the full command to run the jar. This will return a new buffer containing
+ *
+ * java [jvmOptions] -jar "[jarPath]" [argv[0]] [argv[1]] ...
+ */
+PTSTR assembleJvmCommand(PTSTR customizedJavaCmd, PTSTR pathToJar, PTSTR jvmOptions, int argc, _TCHAR* argv[]);
+
+
+/**
+ * Print an error message to stderr containing the human readable error message
+ * corresponding to the GetLastError's return value.
+ */
+void printErrorMessage(DWORD errorCode, ...);
+
+
+/**
+ * A PHANDLER_ROUTINE to handle receiving console control events such as
+ * Ctrl+C. Upon receiving a console control event, it sends the same event
+ * to the JVM (which it finds via the PID stored in the global jvmPid
+ * variable).
+ *
+ * The handler does not further shutdown, since as soon as the JVM dies,
+ * the standard logic in _tmain will handle exiting this program as well.
+ */
+BOOL killJvm(DWORD interruptCode);
+
+#endif
\ No newline at end of file
diff --git a/launchers/shim/shim/shim.vcxproj b/launchers/shim/shim/shim.vcxproj
new file mode 100755
index 00000000..d72fed90
--- /dev/null
+++ b/launchers/shim/shim/shim.vcxproj
@@ -0,0 +1,167 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {830BB6EA-1A0C-4BFB-BD9B-E36F39ABF21C}
+ Win32Proj
+ shim
+
+
+
+ Application
+ true
+ v110
+ Unicode
+
+
+ Application
+ true
+ v110
+ Unicode
+
+
+ Application
+ false
+ v110_xp
+ true
+ Unicode
+
+
+ Application
+ false
+ v110_xp
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ Use
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDebug
+
+
+ Console
+ true
+ RequireAdministrator
+
+
+
+
+ Use
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDebug
+
+
+ Console
+ true
+ RequireAdministrator
+
+
+
+
+ Level3
+ Use
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ MultiThreaded
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ Use
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ MultiThreaded
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+ Create
+ Create
+
+
+
+
+
+
\ No newline at end of file
diff --git a/launchers/shim/shim/shim.vcxproj.filters b/launchers/shim/shim/shim.vcxproj.filters
new file mode 100755
index 00000000..e2e7ae36
--- /dev/null
+++ b/launchers/shim/shim/shim.vcxproj.filters
@@ -0,0 +1,39 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/launchers/shim/shim/shim.vcxproj.user b/launchers/shim/shim/shim.vcxproj.user
new file mode 100755
index 00000000..6fcdb2ce
--- /dev/null
+++ b/launchers/shim/shim/shim.vcxproj.user
@@ -0,0 +1,23 @@
+
+
+
+ SPLUNKD_PROCESSID=1416
+$(LocalDebuggerEnvironment)
+ WindowsLocalDebugger
+
+
+ SPLUNKD_PROCESSID=1416$(LocalDebuggerEnvironment)
+ WindowsLocalDebugger
+
+
+
+
+ --scheme
+ SPLUNKD_PROCESSID=1416
+ WindowsLocalDebugger
+
+
+ SPLUNKD_PROCESSID=1416
+ WindowsLocalDebugger
+
+
\ No newline at end of file
diff --git a/launchers/shim/shim/stdafx.cpp b/launchers/shim/shim/stdafx.cpp
new file mode 100755
index 00000000..ccd66401
--- /dev/null
+++ b/launchers/shim/shim/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// shim.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/launchers/shim/shim/stdafx.h b/launchers/shim/shim/stdafx.h
new file mode 100755
index 00000000..47a0d025
--- /dev/null
+++ b/launchers/shim/shim/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include
+#include
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/launchers/shim/shim/targetver.h b/launchers/shim/shim/targetver.h
new file mode 100755
index 00000000..90e767bf
--- /dev/null
+++ b/launchers/shim/shim/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include
diff --git a/lib/commons-cli-1.2.jar b/lib/commons-cli-1.2.jar
deleted file mode 100644
index ce4b9fff..00000000
Binary files a/lib/commons-cli-1.2.jar and /dev/null differ
diff --git a/lib/junit-4.8.1.jar b/lib/junit-4.8.1.jar
deleted file mode 100644
index 524cd65c..00000000
Binary files a/lib/junit-4.8.1.jar and /dev/null differ
diff --git a/lib/org-openide-actions.jar b/lib/org-openide-actions.jar
deleted file mode 100644
index ca83aa26..00000000
Binary files a/lib/org-openide-actions.jar and /dev/null differ
diff --git a/lib/org-openide-awt.jar b/lib/org-openide-awt.jar
deleted file mode 100644
index 22972b7c..00000000
Binary files a/lib/org-openide-awt.jar and /dev/null differ
diff --git a/lib/org-openide-compat.jar b/lib/org-openide-compat.jar
deleted file mode 100644
index af1b2740..00000000
Binary files a/lib/org-openide-compat.jar and /dev/null differ
diff --git a/lib/org-openide-dialogs.jar b/lib/org-openide-dialogs.jar
deleted file mode 100644
index 06dcceb9..00000000
Binary files a/lib/org-openide-dialogs.jar and /dev/null differ
diff --git a/lib/org-openide-execution.jar b/lib/org-openide-execution.jar
deleted file mode 100644
index 47e7cf92..00000000
Binary files a/lib/org-openide-execution.jar and /dev/null differ
diff --git a/lib/org-openide-explorer.jar b/lib/org-openide-explorer.jar
deleted file mode 100644
index e15ac8af..00000000
Binary files a/lib/org-openide-explorer.jar and /dev/null differ
diff --git a/lib/org-openide-filesystems.jar b/lib/org-openide-filesystems.jar
deleted file mode 100644
index 1b1c581e..00000000
Binary files a/lib/org-openide-filesystems.jar and /dev/null differ
diff --git a/lib/org-openide-io.jar b/lib/org-openide-io.jar
deleted file mode 100644
index 49522467..00000000
Binary files a/lib/org-openide-io.jar and /dev/null differ
diff --git a/lib/org-openide-loaders.jar b/lib/org-openide-loaders.jar
deleted file mode 100644
index 0b36eb66..00000000
Binary files a/lib/org-openide-loaders.jar and /dev/null differ
diff --git a/lib/org-openide-modules.jar b/lib/org-openide-modules.jar
deleted file mode 100644
index 6008a329..00000000
Binary files a/lib/org-openide-modules.jar and /dev/null differ
diff --git a/lib/org-openide-nodes.jar b/lib/org-openide-nodes.jar
deleted file mode 100644
index ec1c9722..00000000
Binary files a/lib/org-openide-nodes.jar and /dev/null differ
diff --git a/lib/org-openide-options.jar b/lib/org-openide-options.jar
deleted file mode 100644
index 88b2fb30..00000000
Binary files a/lib/org-openide-options.jar and /dev/null differ
diff --git a/lib/org-openide-text.jar b/lib/org-openide-text.jar
deleted file mode 100644
index 819a9e20..00000000
Binary files a/lib/org-openide-text.jar and /dev/null differ
diff --git a/lib/org-openide-util-enumerations.jar b/lib/org-openide-util-enumerations.jar
deleted file mode 100644
index 1bd943a3..00000000
Binary files a/lib/org-openide-util-enumerations.jar and /dev/null differ
diff --git a/lib/org-openide-util-lookup.jar b/lib/org-openide-util-lookup.jar
deleted file mode 100644
index c9a082b2..00000000
Binary files a/lib/org-openide-util-lookup.jar and /dev/null differ
diff --git a/lib/org-openide-util.jar b/lib/org-openide-util.jar
deleted file mode 100644
index feb7c432..00000000
Binary files a/lib/org-openide-util.jar and /dev/null differ
diff --git a/lib/org-openide-windows.jar b/lib/org-openide-windows.jar
deleted file mode 100644
index 57c7cf76..00000000
Binary files a/lib/org-openide-windows.jar and /dev/null differ
diff --git a/licenses/LICENSE-COMMONS b/licenses/LICENSE-COMMONS
new file mode 100644
index 00000000..7a4a3ea2
--- /dev/null
+++ b/licenses/LICENSE-COMMONS
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
\ No newline at end of file
diff --git a/licenses/LICENSE-GSON b/licenses/LICENSE-GSON
new file mode 100644
index 00000000..7a4a3ea2
--- /dev/null
+++ b/licenses/LICENSE-GSON
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
\ No newline at end of file
diff --git a/licenses/LICENSE-JACOCO b/licenses/LICENSE-JACOCO
new file mode 100644
index 00000000..e19f0de1
--- /dev/null
+++ b/licenses/LICENSE-JACOCO
@@ -0,0 +1,74 @@
+Eclipse Public License - v 2.0
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+“Contribution” means:
+
+a) in the case of the initial Contributor, the initial content Distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+i) changes to the Program, and
+ii) additions to the Program;
+where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works.
+“Contributor” means any person or entity that Distributes the Program.
+
+“Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+“Program” means the Contributions Distributed in accordance with this Agreement.
+
+“Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors.
+
+“Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
+
+“Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof.
+
+“Distribute” means the acts of a) distributing or b) making available in any manner that enables the transfer of a copy.
+
+“Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+“Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor.
+
+2. GRANT OF RIGHTS
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works.
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+e) Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3).
+3. REQUIREMENTS
+3.1 If a Contributor Distributes the Program in any form, then:
+
+a) the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and
+b) the Contributor may Distribute the Program under a license different than this Agreement, provided that such license:
+i) effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+ii) effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+iii) does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and
+iv) requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3.
+3.2 When the Program is Distributed as Source Code:
+
+a) it must be made available under this Agreement, or if the Program (i) is combined with other material in a separate file or files made available under a Secondary License, and (ii) the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and
+b) a copy of this Agreement must be included with each copy of the Program.
+3.3 Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (‘notices’) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices.
+
+4. COMMERCIAL DISTRIBUTION
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version.
+
+Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement.
+
+Exhibit A – Form of Secondary Licenses Notice
+“This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}.”
\ No newline at end of file
diff --git a/licenses/LICENSE-JUNIT b/licenses/LICENSE-JUNIT
new file mode 100644
index 00000000..3fa00836
--- /dev/null
+++ b/licenses/LICENSE-JUNIT
@@ -0,0 +1,86 @@
+Eclipse Public License - v 1.0
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
\ No newline at end of file
diff --git a/licenses/LICENSE-NETBEANS b/licenses/LICENSE-NETBEANS
new file mode 100644
index 00000000..4c9ad980
--- /dev/null
+++ b/licenses/LICENSE-NETBEANS
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/licenses/LICENSE-OPENCSV b/licenses/LICENSE-OPENCSV
new file mode 100644
index 00000000..8ca90d00
--- /dev/null
+++ b/licenses/LICENSE-OPENCSV
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..37ef9e19
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,91 @@
+
+
+ 4.0.0
+
+
+ 1.9.5
+ true
+ UTF-8
+ 8
+ 8
+
+
+ com.splunk
+ splunk-sdk-java
+ 1.0.1
+ pom
+ Splunk SDK for Java
+ https://dev.splunk.com/enterprise/docs/devtools/java/sdk-java
+
+
+
+ com.google.code.gson
+ gson
+ 2.8.9
+
+
+ net.sf.opencsv
+ opencsv
+ 2.3
+
+
+
+ splunk
+ examples
+
+
+
+ package
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ 3.0.0-M1
+
+ false
+
+
+
+
+
+
+
+ splunk-artifactory
+ Splunk Releases
+ https://splunk.jfrog.io/splunk/ext-releases-local
+
+
+
+
+
+ splunk-artifactory
+ Splunk Releases
+ https://splunk.jfrog.io/splunk/ext-releases-local
+
+
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ Splunk, Inc.
+ http://dev.splunk.com
+
+
diff --git a/results.json b/results.json
new file mode 100644
index 00000000..bae99b06
--- /dev/null
+++ b/results.json
@@ -0,0 +1,2 @@
+
+{"preview":false,"init_offset":0,"messages":[{"type":"DEBUG","text":"base lispy: [ AND index::_internal ]"},{"type":"DEBUG","text":"search context: user=\"admin\", app=\"search\", bs-pathname=\"/Users/fross/splunks/splunk-5.0/etc\""}],"fields":["_bkt","_cd","_indextime","_raw","_serial","_si","_sourcetype","_subsecond","_time","host","index","linecount","source","sourcetype","splunk_server"],"rows":[["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25618","1351880441","127.0.0.1 - - [02/Nov/2012:11:20:40.353 -0700] \"POST /services/search/jobs HTTP/1.1\" 400 191 - - - 1ms","0",["fross-mbp15.local","_internal"],"splunkd_access",".353","2012-11-02T11:20:40.353-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/splunkd_access.log","splunkd_access","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25610","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=udpin_connections, *:9999, sourcePort=9999, _udp_bps=0.00, _udp_kbps=0.00, _udp_avg_thruput=0.00, _udp_kprocessed=0.00, _udp_eps=0.00","1",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25605","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=tpool, name=indexertpool, qsize=0, workers=6, qwork_units=0","2",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25600","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=tpool, name=bundlereplthreadpool, qsize=0, workers=0, qwork_units=0","3",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25595","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=tpool, name=batchreadertpool, qsize=0, workers=1, qwork_units=0","4",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25578","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=subtask_seconds, task=indexer_service, replicate_semislice=0.000000, sync_hotBkt=0.000000, throttle_optimize=0.000765, flushBlockSig=0.000000, retryMove_1hotBkt=0.000000, size_hotBkt=0.000000, roll_hotBkt=0.000000, chillOrFreeze=0.000000, update_checksums=0.000000, fork_recovermetadata=0.000000, rebuild_metadata=0.000000, update_bktManifest=0.000000, service_volumes=0.000030, service_maxSizes=0.000015, service_externProc=0.000015","5",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25572","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=search_concurrency, system total, active_hist_searches=0, active_realtime_searches=0","6",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25567","1351880437","11-02-2012 11:20:37.093 -0700 INFO Metrics - group=realtime_search_data, system total, drop_count=0","7",["fross-mbp15.local","_internal"],"splunkd",".093","2012-11-02T11:20:37.093-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25560","1351880437","11-02-2012 11:20:37.092 -0700 INFO Metrics - group=queue, name=udpin, max_size_kb=500, current_size_kb=0, current_size=0, largest_size=0, smallest_size=0","8",["fross-mbp15.local","_internal"],"splunkd",".092","2012-11-02T11:20:37.092-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"],["_internal~31~02DF1FF2-4F8D-4766-BCCD-4859C4AB3380","31:25553","1351880437","11-02-2012 11:20:37.092 -0700 INFO Metrics - group=queue, name=typingqueue, max_size_kb=500, current_size_kb=0, current_size=0, largest_size=48, smallest_size=0","9",["fross-mbp15.local","_internal"],"splunkd",".092","2012-11-02T11:20:37.092-07:00","fross-mbp15.local","_internal","1","/Users/fross/splunks/splunk-5.0/var/log/splunk/metrics.log","splunkd","fross-mbp15.local"]]}
\ No newline at end of file
diff --git a/run b/run
index 1cd6c370..8d30444d 100755
--- a/run
+++ b/run
@@ -1,29 +1,28 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 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.
-
-"""Helper script for running Java SDK examples."""
-
-from subprocess import Popen
-import sys
-
-if len(sys.argv) == 1: sys.exit(0)
-cmdline = "java -jar dist/examples/%s.jar" % sys.argv[1]
-cmdline = cmdline.split()
-cmdline.extend(sys.argv[2:])
-process = Popen(cmdline, env={})
-process.communicate()
-process.wait()
-
+#!/usr/bin/env python
+#
+# Copyright 2011 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.
+
+"""Helper script for running Java SDK examples."""
+
+from subprocess import Popen
+import sys
+
+if len(sys.argv) == 1: sys.exit(0)
+cmdline = "java -jar dist/examples/%s.jar" % sys.argv[1]
+cmdline = cmdline.split()
+cmdline.extend(sys.argv[2:])
+process = Popen(cmdline, env={})
+process.communicate()
+sys.exit(process.wait())
diff --git a/scripts/test_specific.sh b/scripts/test_specific.sh
new file mode 100644
index 00000000..34aac979
--- /dev/null
+++ b/scripts/test_specific.sh
@@ -0,0 +1,2 @@
+echo "To run a specific test:"
+echo " mvn test -Dtest=[testclass]"
diff --git a/splunk-sdk/.classpath b/splunk-sdk/.classpath
deleted file mode 100644
index ae7c037d..00000000
--- a/splunk-sdk/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/splunk-sdk/.project b/splunk-sdk/.project
deleted file mode 100644
index 50a50ef4..00000000
--- a/splunk-sdk/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Splunk SDK Internal
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/splunk-sdk/splunk-sdk.iml b/splunk-sdk/splunk-sdk.iml
deleted file mode 100644
index ed5b37d9..00000000
--- a/splunk-sdk/splunk-sdk.iml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/splunk/com/splunk/Application.java b/splunk/com/splunk/Application.java
deleted file mode 100644
index 92d318d0..00000000
--- a/splunk/com/splunk/Application.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk application, commonly referred to as an 'app'.
- */
-public class Application extends Entity {
-
- /**
- * Class constructor.
- *
- * @param service The connected service instance.
- * @param path The application endpoint.
- */
- Application(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the app's author name, or null if not specified. If a splunkbase
- * app, this should be the username of the splunk.com account. For internal
- * apps, this should be full contact info.
- *
- * @return Splunk author's name string.
- */
- public String getAuthor() {
- return getString("author", null);
- }
-
- /**
- * Returns whether or not Splunk checks splunkbase for updates.
- *
- * @return Whether or not Splunk checks splunkbase for updates.
- */
- public boolean getCheckForUpdates() {
- return getBoolean("check_for_updates", false);
- }
-
- /**
- * Returns the description string which is a short explanatory note that
- * is displayed underneath the app's title in Launcher, or null if not
- * specified.
- *
- * @return The description string.
- */
- public String getDescription() {
- return getString("description", null);
- }
-
- /**
- * Returns the label string of the app which shows in the Splunk GUI or
- * Launcher, or null if not specified.
- *
- * @return The label string.
- */
- public String getLabel() {
- return getString("label", null);
- }
-
- /**
- * Returns the version string of the app, or null if not specified.
- *
- * @return The version string of the app.
- */
- public String getVersion() {
- return getString("version", null);
- }
-
- /**
- * Returns an indication if the app's custom setup has been
- * performed. This field is only available in Splunk's version 4.2.4+.
- *
- * @return Indicates if the app's custom setup has been performed.
- */
- public boolean isConfigured() {
- return getBoolean("configured", false);
- }
-
- /**
- * Returns whether or not the app can be managed by Splunk Manager.
- *
- * @return Indicates if the app can be managed by Splunk Manager or not.
- */
- public boolean isManageable() {
- return getBoolean("manageable", false);
- }
-
- /**
- * Returns whether or not an app is visible and navigable from the Splunk
- * GUI.
- *
- * @return Indicates if the app is visible and navigable from the Splunk
- * GUI.
- */
- public boolean isVisible() {
- return getBoolean("visible", false);
- }
-
- /**
- * Indicates whether ot not an app state change requires the app to be
- * restarted.
- *
- * @return Indicates if the app needs to be restarted.
- */
- public boolean stateChangeRequiresRestart() {
- return getBoolean("state_change_requires_restart", false);
- }
-
- /**
- * Archives the appliction into a .spl file on the server's file system.
- * The return object contains location specific information.
- *
- * @return Archival information of the app.
- */
- public ApplicationArchive archive() {
- return new ApplicationArchive(service, path);
- }
-
- /**
- * Returns the the app's setup information.
- *
- * @return Returns the app's setup information.
- */
- public ApplicationSetup setup() {
- return new ApplicationSetup(service, path);
- }
-
- /**
- * Returns update information of the app.
- *
- * @return Returns update information for the app.
- */
- public ApplicationUpdate update() {
- return new ApplicationUpdate(service, path);
- }
-}
-
diff --git a/splunk/com/splunk/AtomEntry.java b/splunk/com/splunk/AtomEntry.java
deleted file mode 100644
index aa74fb8a..00000000
--- a/splunk/com/splunk/AtomEntry.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2011 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.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Representation of an Atom entry element.
- */
-public class AtomEntry extends AtomObject {
- /** The value of the Atom entry's {@code published} element. */
- public String published;
-
- /** The value of the Atom entry's {@code content} element. */
- public Record content;
-
- /**
- * Creates a new AtomEntry instance.
- *
- * @return A new AtomEntry instance. ––
- */
- static AtomEntry create() {
- return new AtomEntry();
- }
-
- /**
- * Creates a new {@code AtomEntry} instanced based on the given stream.
- * There are a few endpoints, such as {@code search/jobs/{sid}}, that
- * return an Atom entry element as the root of the response.
- *
- * @param input The input stream.
- * @return An {@code AtomEntry} instance representing the parsed stream.
- */
- public static AtomEntry parse(InputStream input) {
- Element root = Xml.parse(input).getDocumentElement();
- String rname = root.getTagName();
- String xmlns = root.getAttribute("xmlns");
- if (!rname.equals("entry") ||
- !xmlns.equals("http://www.w3.org/2005/Atom"))
- throw new RuntimeException("Unrecognized format");
- return AtomEntry.parse(root);
- }
-
- /**
- * Create a new {@code AtomEntry} instance based on the given XML element.
- *
- * @param element The XML element.
- * @return An {@code AtomEntry} instance representing the parsed element.
- */
- static AtomEntry parse(Element element) {
- AtomEntry entry = AtomEntry.create();
- entry.load(element);
- return entry;
- }
-
- /**
- * Initialize the current instance from the given XML element.
- *
- * @param element The XML element.
- */
- @Override void init(Element element) {
- String name = element.getTagName();
- if (name.equals("published")) {
- this.published = element.getTextContent().trim();
- }
- else if (name.equals("content")) {
- this.content = parseContent(element);
- }
- else {
- super.init(element);
- }
- }
-
- /**
- * Returns a filtered list of child XML element nodes. This is a helper
- * function that makes it a little easier to get only the element children
- * of an XML element.
- *
- * @param element The XML element to return child nodes for.
- * @return A list of child element nodes.
- */
- static ArrayList getChildElements(Element element) {
- ArrayList result = new ArrayList();
- for (Node child = element.getFirstChild();
- child != null;
- child = child.getNextSibling())
- if (child.getNodeType() == Node.ELEMENT_NODE)
- result.add((Element)child);
- return result;
- }
-
- /**
- * Parse the {@code } element of an Atom entry.
- *
- * @param element The XML element to parse.
- * @return A record object containing the parsed values.
- */
- Record parseContent(Element element) {
- assert(element.getTagName().equals("content"));
-
- Record content = null;
-
- List children = getChildElements(element);
-
- int count = children.size();
-
- // Expect content to be empty or a single } content element and return a Record object
- * containing the parsed values.
- *
- * @param element The dict element to parse.
- * @return A record object containing the parsed values.
- */
- Record parseDict(Element element) {
- assert(element.getTagName().equals("s:dict"));
-
- if (!element.hasChildNodes()) return null;
-
- List children = getChildElements(element);
-
- int count = children.size();
- if (count == 0) return null;
-
- Record result = new Record();
- for (Element child : children) {
- assert(child.getTagName().equals("s:key"));
- String key = child.getAttribute("name");
- Object value = parseValue(child);
- if (value != null) result.put(key, value);
- }
- return result;
- }
-
- /**
- * Parse a {@code } element and return a List object containing the parsed
- * values.
- *
- * @param element The list element to parse.
- * @return A list object containing the parsed values.
- */
- List parseList(Element element) {
- assert(element.getTagName().equals("s:list"));
-
- if (!element.hasChildNodes()) return null;
-
- List children = getChildElements(element);
-
- int count = children.size();
- if (count == 0) return null;
-
- List result = new ArrayList(count);
- for (Element child : children) {
- assert(child.getTagName().equals("s:item"));
- Object value = parseValue(child);
- if (value != null) result.add(value);
- }
- return result;
- }
-
- /**
- * Parse the value content of a dict/key or a list/item element. The value
- * is either text, a {@code } or a {@code }} element.
- *
- * @param element The XML element containing the values to parse.
- * @return An object containing the parsed values. The object is a
- * {@code String} if the source was a text value, it is a
- * {@code Record} object if the source was a {@code } element
- * and it is a {@code List} object if the source was a
- * element.
- */
- Object parseValue(Element element) {
- String name = element.getTagName();
-
- assert(name.equals("s:key") || name.equals("s:item"));
-
- if (!element.hasChildNodes()) return null;
-
- List children = getChildElements(element);
-
- int count = children.size();
-
- // If no element children, then it must be a text value
- if (count == 0) return element.getTextContent();
-
- // If its not a text value, then expect a single child element.
- assert(children.size() == 1);
-
- Element child = children.get(0);
-
- name = child.getTagName();
-
- if (name.equals("s:dict"))
- return parseDict(child);
-
- if (name.equals("s:list"))
- return parseList(child);
-
- assert(false); // Unreached
- return null;
- }
-}
diff --git a/splunk/com/splunk/AtomFeed.java b/splunk/com/splunk/AtomFeed.java
deleted file mode 100644
index 192412f2..00000000
--- a/splunk/com/splunk/AtomFeed.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2011 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.InputStream;
-import java.util.ArrayList;
-import org.w3c.dom.Element;
-
-/**
- * Representation of an Atom feed.
- */
-public class AtomFeed extends AtomObject {
- /** The list of Atom entries contained by this Atom feed. */
- public ArrayList entries = new ArrayList();
-
- /** The value of the Atom feed's {@code itemsPerPage} element. */
- public String itemsPerPage = null;
-
- /** The value of the Atom feed's {@code startIndex} element. */
- public String startIndex = null;
-
- /** The value of the Atom feed's {@code totalResults} element. */
- public String totalResults = null;
-
- /**
- * Creates a new AtomFeed instance.
- *
- * @return A new AtomFeed instance.
- */
- static AtomFeed create() {
- return new AtomFeed();
- }
-
- /**
- * Creates a new AtomFeed instance based on the given stream.
- *
- * @param input The input stream.
- * @return An {@code AtomFeed} instance representing the parsed stream.
- */
- public static AtomFeed parse(InputStream input) {
- Element root = Xml.parse(input).getDocumentElement();
- String rname = root.getTagName();
- String xmlns = root.getAttribute("xmlns");
- if (!rname.equals("feed") ||
- !xmlns.equals("http://www.w3.org/2005/Atom"))
- throw new RuntimeException("Unrecognized format");
- return AtomFeed.parse(root);
- }
-
- /**
- * Create a new {@code AtomFeed} instance based on the given XML element.
- *
- * @param element The XML element.
- * @return An {@code AtomFeed} instance representing the parsed element.
- */
- static AtomFeed parse(Element element) {
- AtomFeed feed = AtomFeed.create();
- feed.load(element);
- return feed;
- }
-
- /**
- * Initialize the current instance from the given XML element.
- *
- * @param element The XML element.
- */
- @Override void init(Element element) {
- String name = element.getTagName();
- if (name.equals("entry")) {
- AtomEntry entry = AtomEntry.parse(element);
- this.entries.add(entry);
- }
- else if (name.equals("s:messages")) {
- // Ignore
- }
- else if (name.equals("opensearch:totalResults")) {
- this.totalResults = element.getTextContent().trim();
- }
- else if (name.equals("opensearch:itemsPerPage")) {
- this.itemsPerPage = element.getTextContent().trim();
- }
- else if (name.equals("opensearch:startIndex")) {
- this.startIndex = element.getTextContent().trim();
- }
- else {
- super.init(element);
- }
- }
-}
-
diff --git a/splunk/com/splunk/AtomObject.java b/splunk/com/splunk/AtomObject.java
deleted file mode 100644
index 3cb2875a..00000000
--- a/splunk/com/splunk/AtomObject.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2011 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.HashMap;
-import java.util.Map;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Representation of a generic Atom object. This is a common base class shared
- * by {@code AtomFeed} and {@code AtomEntry}
- */
-public class AtomObject {
- /** The value of the Atom {@code id} element. */
- public String id;
-
- /** The value of any {@code link} elements contains by this Atom object. */
- public Map links = new HashMap();
-
- /** The value of the Atom {@code title} element. */
- public String title;
-
- /** The value of the Atom {@code updated} element. */
- public String updated;
-
- /**
- * Initialize a property of the current instance based on the given XML
- * element.
- *
- * @param element The XML element.
- */
- void init(Element element) {
- String name = element.getTagName();
- if (name.equals("id")) {
- this.id = element.getTextContent().trim();
- }
- else if (name.equals("link")) {
- String rel = element.getAttribute("rel");
- String href = element.getAttribute("href");
- this.links.put(rel, href);
- }
- else if (name.equals("title")) {
- this.title = element.getTextContent().trim();
- }
- else if (name.equals("updated")) {
- this.updated = element.getTextContent().trim();
- }
- else if (name.equals("author") || name.equals("generator")) {
- // Ignore
- }
- else {
- // Ignore
- }
- }
-
- /**
- * Initialize the current instance from the given XML element by calling
- * {@code init} on each child of the XML element.
- *
- * @param element The XML element.
- */
- void load(Element element) {
- for (Node child = element.getFirstChild();
- child != null;
- child = child.getNextSibling())
- {
- if (child.getNodeType() != Node.ELEMENT_NODE)
- continue;
- init((Element)child);
- }
- }
-}
diff --git a/splunk/com/splunk/DeploymentClient.java b/splunk/com/splunk/DeploymentClient.java
deleted file mode 100644
index 58ec33d2..00000000
--- a/splunk/com/splunk/DeploymentClient.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of the Splunk deployment client
- */
-public class DeploymentClient extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- */
- DeploymentClient(Service service) {
- super(service, "deployment/client");
- }
-
- /**
- * Returns the action path.
- *
- * @param action The requested action.
- * @return The action path.
- */
- @Override protected String actionPath(String action) {
- if (action.equals("edit"))
- return path + "/deployment-client";
- return super.actionPath(action);
- }
-
- /**
- * Disables the deployment client.
- */
- @Override public void disable() {
- /*
- * disable is not handled through the standard enable/disable action
- * paths; rather it is an edit (i.e. update) action path.
- */
- Args args = new Args("disabled", true);
- update(args);
- }
-
- /**
- * Enables the deployment client.
- */
- @Override public void enable() {
- /*
- * enable is not handled through the standard enable/disable action
- * path; rather it is an edit (i.e. update) action path.
- */
- Args args = new Args("disabled", false);
- update(args);
- }
-
- /**
- * Returns the list of server classes, or null if not specified.
- *
- * @return The list of server clasess.
- */
- public String [] getServerClasses() {
- return getStringArray("serverClasses", null);
- }
-
- /**
- * Returns the target URI of the deployment server for this deployment
- * client, or null if not specified. The format returned is server:port.
- *
- * @return The target URI for the deployment server.
- */
- public String getTargetUri() {
- return getString("targetUri", null);
- }
-
- /**
- * Reload the deployment client fom the conf file.
- */
- public void reload() {
- service.get(path + "/deployment-client/Reload");
- invalidate();
- }
-}
-
diff --git a/splunk/com/splunk/DeploymentServer.java b/splunk/com/splunk/DeploymentServer.java
deleted file mode 100644
index bfd7af80..00000000
--- a/splunk/com/splunk/DeploymentServer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk deployment server
- */
-public class DeploymentServer extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The deployment server endpoint.
- */
- DeploymentServer(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns whether or not this deployment server reviews its configuration
- * information and informs the deployment client if something is new or
- * updated.
- *
- * @return Whether this deployment server notifies the deployment client for
- * new or changed configurations.
- */
- public boolean getCheckNew() {
- return getBoolean("check-new", false);
- }
-
- /**
- * Returns inclusive criteria for determining deployment client access to
- * this deployment server.
- *
- * @return Criteria for determining deployment client access to this
- * deployment server.
- */
- public String getWhiteList0() {
- return getString("whitelist.0");
- }
-}
diff --git a/splunk/com/splunk/DeploymentServerClass.java b/splunk/com/splunk/DeploymentServerClass.java
deleted file mode 100644
index 9ce8b679..00000000
--- a/splunk/com/splunk/DeploymentServerClass.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk deployment server class.
- */
-public class DeploymentServerClass extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The deployment server class endpoint.
- */
- DeploymentServerClass(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns a comma separated list of hosts excluded from this server class,
- * or null if not specified.
- *
- * @return A comma separated list of hosts excluded from this server class.
- */
- public String getBlackList() {
- return getString("blacklist", null);
- }
-
- /**
- * Return excluded client address by index, or null if not specified.
- *
- * @return Excluded client address by index.
- */
- public String getBlackListByIndex(int index) {
- return getString(String.format("blacklist.%d", index), null);
- }
-
- /**
- * Returns whether lookups halt on first server match (false) or continues
- * to match against multiple servers (true).
- *
- * @return whether server matches first or multiple servers.
- */
- public boolean getContinueMatching() {
- return getBoolean("continueMatching");
- }
-
- /**
- * Returns the URL endpoint for deployment client content downloads, or null
- * if not specified.
- *
- * @return URL endpoint for deployment client downloads.
- */
- public String getEndpoint() {
- return getString("endpoint", null);
- }
-
- /**
- * Returns the filter type applied first. If filterType is whitelist, all
- * whitelist filters are applied first, followed by blacklist filters. If
- * filterType is blacklist, all blacklist filters are applied first,
- * followed by whitelist filters.
- *
- * @return Filter type.
- */
- public String getFilterType() {
- return getString("filterType");
- }
-
- /**
- * Returns the deployment server content storage file path. Note that the
- * path may contain macro expansions or substitutions.
- *
- * @return The deployment server content storage file path.
- */
- public String getRepositoryLocation() {
- return getString("repositoryLocation");
- }
-
- /**
- * Returns the deployment client content storage file path, or null if not
- * specified. Note that the path may contain macro expansions or
- * substitutions.
- *
- * @return The deployment client content storage file path.
- */
- public String getTargetRepositoryLocation() {
- return getString("targetRepositoryLocation", null);
- }
-
- /**
- * Returns the deployment server's working file path, or null if not
- * specified. Note that the path may contain macro expansions or
- * substitutions.
- *
- * @return the deployment server's working file path.
- */
- public String getTmpFolder() {
- return getString("tmpFolder", null);
- }
-
- /**
- * Returns a comma separated list of hosts included for this server class,
- * or null if not specified.
- *
- * @return A comma separated list of hosts included for this server class.
- */
- public String getWhiteList() {
- return getString("whitelist", null);
- }
-
- /**
- * Return included client address by index, or null if not specified.
- *
- * @return Included client address by index.
- */
- public String getWhiteListByIndex(int index) {
- return getString(String.format("whitelist.%d", index), null);
- }
-}
diff --git a/splunk/com/splunk/DistributedConfiguration.java b/splunk/com/splunk/DistributedConfiguration.java
deleted file mode 100644
index ffe0a65d..00000000
--- a/splunk/com/splunk/DistributedConfiguration.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk distributed search configuration.
- */
-public class DistributedConfiguration extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- */
- DistributedConfiguration(Service service) {
- super(service, "search/distributed/config");
- }
-
- /**
- * Returns the action path.
- *
- * @param action The requested action.
- * @return The action path.
- */
- @Override protected String actionPath(String action) {
- if (action.equals("edit"))
- return path + "/distributedSearch";
- return super.actionPath(action);
- }
-
- /**
- * Returns whether Splunk automatically discovers other servers.
- *
- * @return whether Splunk automatically discovers other servers.
- */
- public boolean getAutoAddServers() {
- return getBoolean("autoAddServers");
- }
-
- /**
- * Returns a comma separated list of server names that are excluded from
- * being peers, or null if not available.
- *
- * @return servers, by name, that are excluded from being peers.
- */
- public String getBlacklistNames() {
- return getString("blacklistNames", null);
- }
-
- /**
- * Returns a comma separated list of server URLs that are excluded from
- * being peers. URLs are in the form x.x.x.x:port, or null if not available.
- *
- * @return servers, by URL, that are excluded from being peers.
- */
- public String getBlacklistUrls() {
- return getString("blacklistURLs", null);
- }
-
- /**
- * Return connection timeout in seconds, or -1 if not specified.
- *
- * @return The connection timeout in seconds.
- */
- public int getConnectionTimeout() {
- return getInteger("connectionTimeout", -1);
- }
-
- /**
- * Returns the number of seconds between checking servers that are already
- * timed-out. Zero means do not recheck. The default is sixty seconds. If
- * removeTimedOutServers is false the setting has no effect.
- *
- * @return The number of seconds to check timed-out servers.
- */
- public int getCheckTimedOutServersFrequency() {
- return getInteger("checkTimedOutServersFrequency");
- }
-
- /**
- * Returns the number of seconds between checking on other servers health.
- * If set to zero, heartbeat checks are disabled.
- *
- * @return The number of seconds between checking on other servers health.
- */
- public int getHeartbeatFrequency() {
- return getInteger("heartbeatFrequency");
- }
-
- /**
- * Returns the multi-cast address to discover other servers and receive
- * heartbeats, or null if not available.
- *
- * @return The multi-cast address for discovery and heartbeat messages.
- */
- public String getHeartbeatMcastAddress() {
- return getString("heartbeatMcastAddr", null);
- }
-
- /**
- * Returns the port used for heartbeat messages.
- *
- * @return The heatbeat port.
- */
- public int getHeartbeatPort() {
- return getInteger("heartbeatPort");
- }
-
- /**
- * Returns receive timeout in seconds, or -1 if not specified.
- *
- * @return The receive timeout in seconds.
- */
- public int getReceiveTimeout() {
- return getInteger("receiveTimeout", -1);
- }
-
- /**
- * Returns whether or not timed out servers are removed from the distributed
- * configuration.
- *
- * @return whether ot not timed out servers are removed from the distributed
- * configuration.
- */
- public boolean getRemovedTimedOutServers() {
- return getBoolean("removedTimedOutServers");
- }
- /**
- * @deprecated Use specific connectionTimeout, receiveTimeout, sendTimeout.
- *
- * Returns the timeout in seconds, to determine a server timeout.
- *
- * @return The timeout in seconds, to determine a server timeout.
- */
- public int getServerTimeout() {
- return getInteger("serverTimeout");
- }
-
- /**
- * Returns send timeout in seconds, or -1 if not specified.
- *
- * @return The send timeout in seconds.
- */
- public int getSendTimeout() {
- return getInteger("sendTimeout", -1);
- }
-
- /**
- * Returns a comma separated list of peer servers, or null if not available.
- *
- * @return The list of peer servers.
- */
- public String getServers() {
- return getString("servers", null);
- }
-
- /**
- * Returns whether or not this server uses bundle replication to share
- * search time configuration with search peers. Note: if set to false,
- * the search head assumes the search peers can access a bundles through
- * shared storage (NAS).
- *
- * @return whether or not this server uses bundle replication.
- */
- public boolean getShareBundles() {
- return getBoolean("shareBundles");
- }
-
- /**
- * Returns whether or not this server participates in a search. If set to
- * true, this server does NOT participate as a server in any search or other
- * call. This is used for building a node that does nothing but merge the
- * results from other servers.
- *
- * @return Whether or not this server participates in a search.
- */
- public boolean getSkipOurselves() {
- return getBoolean("skipOurselves");
- }
-
- /**
- * Returns the number of seconds for connection timeouts when gathering a
- * search peer's basic information.
- *
- * @return The number of seconds for connection timeout.
- */
- public int getStatusTimeout() {
- return getInteger("statusTimeout");
- }
-
- /**
- * Returns the time-to-live of heartbeat messages.
- *
- * @return The time-to-live of heartbeat messages.
- */
- public int getTtl() {
- return getInteger("ttl");
- }
-
- /**
- * Returns whether or not distributed search is enabled.
- *
- * @return If distributed search is enabled or disabled.
- */
- public boolean isDistSearchEnabled() {
- return getBoolean("dist_search_enabled");
- }
-}
diff --git a/splunk/com/splunk/DistributedPeer.java b/splunk/com/splunk/DistributedPeer.java
deleted file mode 100644
index 9db13f1e..00000000
--- a/splunk/com/splunk/DistributedPeer.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk distributed peer.
- */
-public class DistributedPeer extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The deployment server endpoint.
- */
- DistributedPeer(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this peer's build number, or null if not specified.
- *
- * @return This peer's build number.
- */
- public String getBuild() {
- return getString("build", null);
- }
-
- /**
- * Returns the list of bundle versions, or null if not specified.
- *
- * @return The list of bundle versions.
- */
- public String[] getBundleVersions() {
- return getStringArray("bundle_versions", null);
- }
-
- /**
- * Returns this peer's GUID, or null if not specified.
- *
- * @return this peer's GUID.
- */
- public String getGuid() {
- return getString("guid", null);
- }
-
- /**
- * Returns this peer's license signature, or null if not specified.
- *
- * @return This peer's license signature.
- */
- public String getLicenseSignature() {
- return getString("licenseSignature", null);
- }
-
- /**
- * Returns this peer's name, or null if not specified.
- *
- * @return Thid peer's name.
- */
- public String getPeerName() {
- return getString("peerName", null);
- }
-
- /**
- * Returns this peer's type, or null if not specified.
- *
- * @return This peer's type.
- */
- public String getPeerType() {
- return getString("peerType", null);
- }
-
- /**
- * Returns this peer's replication status, or null if not specified.
- *
- * @return This peer's replication status.
- */
- public String getReplicationStatus() {
- return getString("replicationStatus", null);
- }
-
- /**
- * Return this peer's overall status, or null if not specified.
- *
- * @return This peer's overall status.
- */
- public String getStatus() {
- return getString("status", null);
- }
-
- /**
- * Returns this peer's version, or null if not specified.
- *
- * @return This peer's version.
- */
- public String getVersion() {
- return getString("version", null);
- }
-
- /**
- * Returns whether or not this peer is using HTTPS, or null if not
- * specified.
- *
- * @return whether or not this peer is using HTTPS.
- */
- public boolean isHttps() {
- return getBoolean("is_https", true);
- }
-}
-
diff --git a/splunk/com/splunk/EntityCollection.java b/splunk/com/splunk/EntityCollection.java
deleted file mode 100644
index 167e0f10..00000000
--- a/splunk/com/splunk/EntityCollection.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a collection of entities.
- *
- * @param The type of members of the collection.
- */
-public class EntityCollection extends ResourceCollection {
-
- /**
- * Class constructor.
- *
- * @param service The connected service instance.
- * @param path The entity's endpoint.
- */
- EntityCollection(Service service, String path) {
- super(service, path, Entity.class);
- }
-
- /**
- * Class constructor.
- *
- * @param service The connected service instance.
- * @param path The entity's endpoint.
- * @param itemClass The entity's subclass.
- */
- public EntityCollection(Service service, String path, Class itemClass) {
- super(service, path, itemClass);
- }
-
- /**
- * Creates an entity in this collection.
- *
- * @param name The name of the entity created.
- * @return The entity.
- */
- public T create(String name) {
- return create(name, null);
- }
-
- /**
- * Creates an entity in this collection.
- *
- * @param name The name of the entity created.
- * @param args The arguments supplied to the creation.
- * @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);
- }
-
- /**
- * Removes an entity from this collection.
- *
- * @param key the name of the entity to remove.
- * @return this collection.
- */
- public T remove(Object key) {
- validate();
- if (!containsKey(key)) return null;
- T entity = items.get(key);
- entity.remove();
- items.remove(key);
- invalidate();
- return entity;
- }
-}
diff --git a/splunk/com/splunk/EventType.java b/splunk/com/splunk/EventType.java
deleted file mode 100644
index ce235da7..00000000
--- a/splunk/com/splunk/EventType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of an event type.
- */
-public class EventType extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The event type endpoint.
- */
- EventType(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the description of this event type.
- *
- * @return The description of this event type.
- */
- public String getDescription() {
- return getString("description", null);
- }
-
- /**
- * Returns the priority of this event type. The range is 1 to 10, with 1
- * beging the highest priority.
- *
- * @return The priority of this event type.
- */
- public int getPriority() {
- return getInteger("priority", -1);
- }
-
- /**
- * Returns this event type's search terms.
- *
- * @return This event types' search terms.
- */
- public String getSearch() {
- return getString("search", null);
- }
-
- /**
- * @deprecated Use tags.conf.spec file to assign tags to groups of events
- * with related field values.
- *
- * Returns this event types list of tags.
- *
- * @return This event types list of tags.
- */
- public String [] getTags() {
- return getStringArray("tags", null);
- }
-}
-
diff --git a/splunk/com/splunk/FiredAlert.java b/splunk/com/splunk/FiredAlert.java
deleted file mode 100644
index ea1be0a9..00000000
--- a/splunk/com/splunk/FiredAlert.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2011 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.Date;
-
-/**
- * Representation of a fired alert.
- */
-public class FiredAlert extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The fired alert endpoint.
- */
- FiredAlert(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this alert's actions, or null if not available.
- *
- * @return This alert's actions.
- */
- public String getAction() {
- return getString("actions", null);
- }
-
- /**
- * Returns this alert's type, or null if not available.
- *
- * @return This alert's type.
- */
- public String getAlertType() {
- return getString("alert_type", null);
- }
-
- /**
- * Returns this alerts's rendered expiration time, or null if not available.
- * (4.3+)
- *
- * @return This alert's rendered expiration time.
- */
- public String getExpirationTime() {
- return getString("expiration_time_rendered", null);
- }
-
- /**
- * Returns this alert's saved search name, or null if not available.
- *
- * @return this alert's saved search name.
- */
- public String getSavedSearchName() {
- return getString("savedsearch_name", null);
- }
-
- /**
- * Returns this alert's severity, on a scale of 1 to 10, with 1 being the
- * highest priority. -1 if value not specified.
- *
- * @return This alert's severity.
- */
- public int getSeverity() {
- return getInteger("severity", -1);
- }
-
- /**
- * Returns this alert's SID, or null if not available.
- *
- * @return This alerts SID.
- */
- public String getSid() {
- return getString("sid", null);
- }
-
- /**
- * Returns the number of triggered alerts, or -1 if not specified (4.3+)
- *
- * @return The number of triggered alerts.
- */
- public int getTriggeredAlertCount() {
- return getInteger("triggered_alerts", -1);
- }
-
- /**
- * Returns this alert's trigger time, or null if not available.
- *
- * @return This alert's trigger time.
- */
- public Date getTriggerTime() {
- return getDateFromEpoch("trigger_time", null);
- }
-
- /**
- * Returns this alert's rendered trigger time, or null if not available.
- * (4.3+)
- *
- * @return This alert's rendered trigger time.
- */
- public String getTriggerTimeRendered() {
- return getString("trigger_time_rendered", null);
- }
-
- /**
- * Returned whether or not the result is a digest, or false if not
- * specified (4.3+)
- *
- * @return whether ot nor the result is a digest.
- */
- public boolean isDigestMode() {
- return getBoolean("digest_mode", false);
- }
-}
diff --git a/splunk/com/splunk/HttpService.java b/splunk/com/splunk/HttpService.java
deleted file mode 100644
index 00ec208b..00000000
--- a/splunk/com/splunk/HttpService.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright 2011 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.OutputStream;
-import java.io.OutputStreamWriter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.ProtocolException;
-import java.net.URL;
-import java.net.Socket;
-import java.security.cert.X509Certificate;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Representation of a generic HTTP service at a given address (host:port)
- * accessed using a given protocol "scheme" ({@code http} or {@code https}).
- */
-public class HttpService {
- /** The scheme used to access the service. */
- protected String scheme = "https";
-
- /** The host name of the service. */
- protected String host = "localhost";
-
- /** The port number of the service. */
- protected int port = 8089;
-
- private String prefix = null;
-
- static Map defaultHeader = new HashMap() {{
- put("User-Agent", "splunk-sdk-java/0.1");
- put("Accept", "*/*");
- }};
-
- TrustManager[] trustAll = new TrustManager[] {
- new X509TrustManager() {
- public X509Certificate[] getAcceptedIssuers() { return null; }
- public void checkClientTrusted(
- X509Certificate[] certs, String authType) { }
- public void checkServerTrusted(
- X509Certificate[] certs, String authType) { }
- }
- };
-
- /** Constructs a new {@code HttpService} instance. */
- public HttpService() {
- setTrustPolicy();
- }
-
- /**
- * Constructs a new {@code HttpService} instance at the given host.
- *
- * @param host Host name of the service.
- */
- public HttpService(String host) {
- this.host = host;
- setTrustPolicy();
- }
-
- /**
- * Constructs a new {@code HttpService} instance at the given host and port.
- *
- * @param host Host name of the service.
- * @param port Port number of the service.
- */
- public HttpService(String host, int port) {
- this.host = host;
- this.port = port;
- setTrustPolicy();
- }
-
- /**
- * Constructs a new {@code HttpService} instance using the given host, port
- * and scheme.
- *
- * @param host Host name of the service.
- * @param port Port number of the service.
- * @param scheme Scheme for accessing the service
- * ({@code http} or {@code https}).
- */
- public HttpService(String host, int port, String scheme) {
- this.host = host;
- this.port = port;
- this.scheme = scheme;
- setTrustPolicy();
- }
-
- // Returns the count of args in the given map
- private static int count(Map args) {
- if (args == null) return 0;
- return args.size();
- }
-
- /**
- * Issue an HTTP GET request against the service using the given path.
- *
- * @param path Request path.
- * @return HTTP response.
- */
- public ResponseMessage get(String path) {
- return send(path, new RequestMessage("GET"));
- }
-
- /**
- * Issue an HTTP GET request against the service using the given path and
- * query arguments.
- *
- * @param path The request path.
- * @param args Query arguments.
- * @return HTTP response.
- */
- public ResponseMessage get(String path, Map args) {
- if (count(args) > 0)
- path = path + "?" + Args.encode(args);
- RequestMessage request = new RequestMessage("GET");
- return send(path, request);
- }
-
- /**
- * Returns the host name of this service.
- *
- * @return Host name.
- */
- public String getHost() {
- return this.host;
- }
-
- /**
- * Returns the port number of this service.
- *
- * @return Port number.
- */
- public int getPort() {
- return this.port;
- }
-
- /**
- * Returns the URL prefix of this service, consisting of
- * {@code scheme://host[:port]}
- *
- * @return URL prefix.
- */
- public String getPrefix() {
- if (this.prefix == null)
- this.prefix = String.format("%s://%s:%s",
- this.scheme, this.host, this.port);
- return this.prefix;
- }
-
- /**
- * Returns the scheme used by this service.
- *
- * @return Scheme.
- */
- public String getScheme() {
- return this.scheme;
- }
-
- /**
- * Construct a fully qualified URL for this service using the given path.
- *
- * @param path The path to qualify.
- * @return Fully qualified URL.
- */
- public URL getUrl(String path) {
- try {
- return new URL(getPrefix() + path);
- }
- catch (MalformedURLException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- /**
- * Issue a POST request against the service using the given path.
- *
- * @param path The request path.
- * @return HTTP response.
- */
- public ResponseMessage post(String path) {
- return post(path, null);
- }
-
- /**
- * Issue a POST request against the service using the given path and
- * form arguments.
- *
- * @param path The request path.
- * @param args Form arguments.
- * @return HTTP response.
- */
- public ResponseMessage post(String path, Map args) {
- RequestMessage request = new RequestMessage("POST");
- request.getHeader().put(
- "Content-Type", "application/x-www-form-urlencoded");
- if (count(args) > 0)
- request.setContent(Args.encode(args));
- return send(path, request);
- }
-
- /**
- * Issue a DELETE request against the service using the given path.
- *
- * @param path The request path.
- * @return HTTP response.
- */
- public ResponseMessage delete(String path) {
- RequestMessage request = new RequestMessage("DELETE");
- return send(path, request);
- }
-
- /**
- * Issue a DELETE request against the service using the given path
- * and query arguments.
- *
- * @param path The request path.
- * @param args Query arguments.
- * @return HTTP response.
- */
- public ResponseMessage delete(String path, Map args) {
- if (count(args) > 0)
- path = path + "?" + Args.encode(args);
- RequestMessage request = new RequestMessage("DELETE");
- return send(path, request);
- }
-
- /**
- * Open a socket to this service.
- *
- * @return Socket
- * @throws IOException
- */
- Socket open() throws IOException {
- if (this.scheme.equals("https")) {
- SSLSocketFactory sslsocketfactory;
- try {
- SSLContext context = SSLContext.getInstance("SSL");
- context.init(null, trustAll, new java.security.SecureRandom());
- sslsocketfactory = context.getSocketFactory();
- }
- catch (Exception e) {
- throw new RuntimeException("Error installing trust manager.");
- }
- return sslsocketfactory.createSocket(this.host, this.port);
- }
- return new Socket(this.host, this.port);
- }
-
- /**
- * Issue an HTTP request against the service using the given path and
- * request message.
- *
- * @param path Request path.
- * @param request Request message.
- * @return HTTP response.
- */
- public ResponseMessage send(String path, RequestMessage request) {
- // Construct a full URL to the resource
- URL url = getUrl(path);
-
- // Create and initialize the connection object
- HttpURLConnection cn;
- try {
- cn = (HttpURLConnection)url.openConnection();
- }
- catch (IOException e) {
- throw new RuntimeException(e.getMessage());
- }
- cn.setUseCaches(false);
- cn.setAllowUserInteraction(false);
-
- // Set the reqeust method
- String method = request.getMethod();
- try {
- cn.setRequestMethod(method);
- }
- catch (ProtocolException e) {
- throw new RuntimeException(e.getMessage());
- }
-
- // Add headers from request message
- Map header = request.getHeader();
- for (Entry entry : header.entrySet())
- cn.setRequestProperty(entry.getKey(), entry.getValue());
-
- // Add default headers that were absent from the request message
- for (Entry entry : defaultHeader.entrySet()) {
- String key = entry.getKey();
- if (header.containsKey(key)) continue;
- cn.setRequestProperty(key, entry.getValue());
- }
-
- // Write out request content, if any
- try {
- Object content = request.getContent();
- if (content != null) {
- cn.setDoOutput(true);
- OutputStream stream = cn.getOutputStream();
- OutputStreamWriter writer = new OutputStreamWriter(stream);
- writer.write((String)content);
- writer.close();
- }
- }
- catch (IOException e) {
- throw new RuntimeException(e.getMessage());
- }
-
- // System.out.format("%s %s => ", method, url.toString());
-
- // Execute the request
- try {
- cn.connect();
- }
- catch (IOException e) {
- throw new RuntimeException(e.getMessage());
- }
-
- int status;
- try {
- status = cn.getResponseCode();
- }
- catch (IOException e) {
- throw new RuntimeException(e.getMessage());
- }
-
- InputStream input = null;
- try {
- input = status >= 400
- ? cn.getErrorStream()
- : cn.getInputStream();
- }
- catch (IOException e) { assert(false); }
-
- ResponseMessage response = new ResponseMessage(status, input);
-
- // System.out.format("%d\n", status);
-
- if (status >= 400)
- throw HttpException.create(response);
-
- return response;
- }
-
- /**
- * Set the trust policy used by this service instance.
- */
- void setTrustPolicy() {
- try {
- SSLContext context = SSLContext.getInstance("SSL");
- context.init(null, trustAll, new java.security.SecureRandom());
- HttpsURLConnection.setDefaultSSLSocketFactory(
- context.getSocketFactory());
- HttpsURLConnection.setDefaultHostnameVerifier(
- new HostnameVerifier() {
- public boolean verify(
- String urlHostName, SSLSession session) { return true; }
- });
- }
- catch (Exception e) {
- throw new RuntimeException("Error installing trust manager.");
- }
- }
-}
-
diff --git a/splunk/com/splunk/Index.java b/splunk/com/splunk/Index.java
deleted file mode 100644
index 93706bdc..00000000
--- a/splunk/com/splunk/Index.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * Copyright 2011 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.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Date;
-import java.net.Socket;
-
-/**
- * Representation of an index.
- */
-public class Index extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The index endpoint.
- */
- Index(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Creates a writable socket to this index.
- *
- * @return The Socket.
- * @throws IOException
- */
- public Socket attach() throws IOException {
- Socket socket = service.open();
- OutputStream ostream = socket.getOutputStream();
- Writer out = new OutputStreamWriter(ostream, "UTF8");
- String header = String.format(
- "POST /services/receivers/stream?index=%s HTTP/1.1\r\n" +
- "Host: %s:%d\r\n" +
- "Accept-Encoding: identity\r\n" +
- "Authorization: %s\r\n" +
- "X-Splunk-Input-Mode: Streaming\r\n\r\n",
- getName(),
- service.getHost(), service.getPort(),
- service.token);
- out.write(header);
- out.flush();
- return socket;
- }
-
- /**
- * Cleans this index, removing all events.
- *
- * @return This index.
- */
- public Index clean() {
- Args saved = new Args();
- saved.put("maxTotalDataSizeMB", getMaxTotalDataSizeMB());
- saved.put("frozenTimePeriodInSecs", getFrozenTimePeriodInSecs());
-
- Args reset = new Args();
- reset.put("maxTotalDataSizeMB", "1");
- reset.put("frozenTimePeriodInSecs", "1");
- update(reset);
- rollHotBuckets();
-
- while (true) {
- try {
- Thread.sleep(1000); // 1000ms (1 second sleep)
- }
- catch (InterruptedException e) {
- return this; // eat
- }
- if (this.getTotalEventCount() == 0)
- break;
- refresh();
- }
- update(saved);
- return this;
- }
-
- /**
- * Returns whether or not data retrieved from this index is in UTF8
- * encoding.
- *
- * @return Whether or not data retrieved from this index is in UTF8.
- */
- public boolean getAssureUTF8() {
- return getBoolean("assureUTF8");
- }
-
- /**
- * Returns this index's block signature database.
- *
- * @return This index's block signature database.
- */
- public String getBlockSignatureDatabase() {
- return getString("blockSignatureDatabase");
- }
-
- /**
- * Returns this index's block sign size. This value defines the number of
- * events that make up a block for block signatures. A value of 0 means
- * block signing is disabled.
- *
- * @return This index's block sign size.
- */
- public int getBlockSignSize() {
- return getInteger("blockSignSize");
- }
-
- /**
- * Returns this index's colddbs's absolute file path, or null if not
- * specified. This value may contain shell expansion terms.
- *
- * @return this index's colddbs's absolute file path.
- */
- public String getColdPath() {
- return getString("coldPath", null);
- }
-
- /**
- * Returns this index's colddbs's expanded absolute file path, or null if
- * not specified.
- *
- * @return this index's colddbs's expanded absolute file path.
- */
- public String getColdPathExpanded() {
- return getString("coldPath_expanded", null);
- }
-
- /**
- * Returns this index's frozen archive destination path, or null if not
- * specified.
- *
- * @return This index's frozen archive destination path.
- */
- public String getColdToFrozenDir() {
- return getString("coldToFrozenDir", null);
- }
-
- /**
- * Returns this index's archiving script, or null if not specified.
- *
- * @see Notes on this attribute
- *
- * @return This index's archiving script
- */
- public String getColdToFrozenScript() {
- return getString("coldToFrozenScript", null);
- }
-
- /**
- * Returns whether or not raw data is compressed.
- *
- * @deprecated Splunk always compresses raw data.
- * @return Whether or not raw data is compressed.
- */
- public boolean getCompressRawdata() {
- return getBoolean("compressRawdata");
- }
-
- /**
- * Returns this index's current size in MBs.
- *
- * @return This index's current size in MB's
- */
- public int getCurrentDBSizeMB() {
- return getInteger("currentDBSizeMB");
- }
-
- /**
- * Return the Splunk instances default index name.
- *
- * @return The Splunk instances default index name.
- */
- public String getDefaultDatabase() {
- return getString("defaultDatabase");
- }
-
- /**
- * Returns whether or not this index has real-time-search enabled.
- *
- * @return Whether or not this index has real-time-search enabled.
- */
- public boolean getEnableRealtimeSearch() {
- return getBoolean("enableRealtimeSearch");
- }
-
- /**
- * Returns how long, in seconds, that this index's data rolls to frozen. If
- * archiving is necessary for frozen data, see coldToFrozen attributes.
- *
- * @return How long, in seconds, that this index's data rolls to frozen.
- */
- public int getFrozenTimePeriodInSecs() {
- return getInteger("frozenTimePeriodInSecs");
- }
-
- /**
- * Returns this index's absolute path to both hot and warm buckets, or null
- * if not specified. This value may contain shell expansion terms.
- *
- * @return This index's absolute path to both hot and warm buckets.
- */
- public String getHomePath() {
- return getString("homePath", null);
- }
-
- /**
- * Returns this index's expanded absolute path to both hot and warm buckets,
- * or null if not specified.
- *
- * @return This index's expanded absolute path to both hot and warm buckets.
- */
- public String getHomePathExpanded() {
- return getString("homePath_expanded", null);
- }
-
- /**
- * Returns this index's index thread.
- *
- * @return This index's index thread.
- */
- public String getIndexThreads() {
- return getString("indexThreads");
- }
-
- /**
- * Returns this index's last initialization time, or null if not specified.
- *
- * @return This index's last initialization time.
- */
- public String getLastInitTime() {
- return getString("lastInitTime", null);
- }
-
- /**
- * Returns this index's maximum number of concurrent optimize processes per
- * hot bucket.
- *
- * @return This index's maximum number of concurrent optimize processes per
- * hot bucket.
- */
- public int getMaxConcurrentOptimizes() {
- return getInteger("maxConcurrentOptimizes");
- }
-
- /**
- * Returns this index's maximum data size, in MB or "auto" or
- * "auto_high_volume", before triggering a roll from hot to warm buckets.
- *
- * @return This index's maximum data size, before triggering a roll from hot
- * to warm buckets.
- */
- public String getMaxDataSize() {
- return getString("maxDataSize");
- }
-
- /**
- * Returns this index's maximum number of hot buckets.
- *
- * @return this index's maximum number of hot buckets.
- */
- public int getMaxHotBuckets() {
- return getInteger("maxHotBuckets");
- }
-
- /**
- * Returns this index's hot bucket's maximum life, in seconds. A value of
- * zero means infinite.
- *
- * @return This index's hot bucket's maximum life, in seconds.
- */
- public int getMaxHotIdleSecs() {
- return getInteger("maxHotIdleSecs");
- }
-
- /**
- * Returns this index's hot/warm bucket upper bound timespan, in seconds.
- *
- * @return This index's hot/warm bucket upper bound timespan, in seconds.
- */
- public int getMaxHotSpanSecs() {
- return getInteger("maxHotSpanSecs");
- }
-
- /**
- * Returns this index's single tsidx file maximum size, in MB.
- *
- * @return This index's single tsidx file maximum size, in MB.
- */
- public int getMaxMemMB() {
- return getInteger("maxMemMB");
- }
-
- /**
- * Returns this index's maximum number of lines permissible in the .data
- * file. A value of zero means infinite.
- *
- * @return This index's maximum number of lines permissible in the .data
- * file.
- */
- public int getMaxMetaEntries() {
- return getInteger("maxMetaEntries");
- }
-
- /**
- * Returns this index's maximum concurrent helper processes.
- *
- * @return This index's maximum concurrent helper processes.
- */
- public int getMaxRunningProcessGroups() {
- return getInteger("maxRunningProcessGroups");
- }
-
- /**
- * Returns this index's max time attribute, or null if not specified.
- *
- * @return This index's max time attribute.
- */
- public Date getMaxTime() {
- return getDate("maxTime", null);
- }
-
- /**
- * Returns this index's maximum allowable size, in MB. If the index grows
- * larger, the oldest data is frozen.
- *
- * @return This index's maximum allowable size, in MB.
- */
- public int getMaxTotalDataSizeMB() {
- return getInteger("maxTotalDataSizeMB");
- }
-
- /**
- * Returns this index's warm bucket count maximum. If this value is
- * exceeded, the warm buckets with oldest latest times are moved to cold.
- *
- * @return This index's warm bucket count maximum.
- */
- public int getMaxWarmDBCount() {
- return getInteger("maxWarmDBCount");
- }
-
- /**
- * Returns this index's memory pool, in MB or "auto".
- *
- * @return This index's memory pool, in MB.
- */
- public String getMemPoolMB() {
- return getString("memPoolMB");
- }
-
- /**
- * Returns this index's file system sync frequency while compressing
- * journal slices. Note that a value of "disable" disables this feature
- * completely, while a value of 0 forces a filesystem sync after
- * every journal slice.
- *
- * @return This index's file system sync frequency while compressing
- * journal slices.
- */
- public String getMinRawFileSyncSecs() {
- return getString("minRawFileSyncSecs");
- }
-
- /**
- * Returns this index's minimum time attribute, or null if not specified.
- *
- * @return This index's minimum time attribute.
- */
- public Date getMinTime() {
- return getDate("minTime", null);
- }
-
- /**
- * Returns this index's meta data sync interval, in seconds. A value of zero
- * disables sync until a requested metadata sync.
- *
- * @return This index's meta data sync interval, in seconds.
- */
- public int getPartialServiceMetaPeriod() {
- return getInteger("partialServiceMetaPeriod");
- }
-
- /**
- * Returns this index's future event time quarantine, in seconds. Events
- * that are newer than now plus this value are quarantined.
- *
- * @return This index's future event time quarantine, in seconds.
- */
- public int getQuarantineFutureSecs() {
- return getInteger("quarantineFutureSecs");
- }
-
- /**
- * Returns this index's past event time quarantine, in seconds. Events
- * that are older than now minus this value are quarantined.
- *
- * @return This index's past event time quarantine, in seconds.
- */
- public int getQuarantinePastSecs() {
- return getInteger("quarantinePastSecs");
- }
-
- /**
- * Returns this index's raw slice uncompressed size, in bytes.
- *
- * @return This index's raw slice uncompressed size, in bytes.
- */
- public int getRawChunkSizeBytes() {
- return getInteger("rawChunkSizeBytes");
- }
-
- /**
- * Returns this index's hot bucket creation check frequency. This value
- * also indicates warm to cold and cold to frozen check frequency.
- *
- * @return This index's hot bucket creation check frequency.
- */
- public int getRotatePeriodInSecs() {
- return getInteger("rotatePeriodInSecs");
- }
-
- /**
- * Returns this index's meta data sync frequency.
- *
- * @return This index's meta data sync frequency.
- */
- public int getServiceMetaPeriod() {
- return getInteger("serviceMetaPeriod");
- }
-
- /**
- * Returns a comma separated list of indexes that suppress index missing
- * messages.
- *
- * @return A comma separated list of indexes that suppress index missing
- * messages.
- */
- public String getSuppressBannerList() {
- return getString("suppressBannerList", null);
- }
-
- /**
- * Returns this index's sync attribute.
- *
- * @return This index's sync attribute.
- */
- public boolean getSync() {
- return getBoolean("sync");
- }
-
- /**
- * Returns this index's syncMeta attribute. When true, a sync operation is
- * invoked before the file descriptor is closed on metadata updates.
- *
- * @return This index's syncMeta attribute.
- */
- public boolean getSyncMeta() {
- return getBoolean("syncMeta");
- }
-
- /**
- * Returns this index's absolute path to the thawed index, or null if not
- * present. This value may contain shell expansion terms.
- *
- * @return This index's absolute path to the thawed index.
- */
- public String getThawedPath() {
- return getString("thawedPath", null);
- }
-
- /**
- * Returns this index's expanded absolute path to the thawed index, or null
- * if not present.
- *
- * @return This index's expanded absolute path to the thawed index.
- */
- public String getThawedPathExpanded() {
- return getString("thawedPath_expanded", null);
- }
-
- /**
- * Returns this index's throttling frequency check, in seconds.
- *
- * @return This index's throttling frequency check, in seconds.
- */
- public int getThrottleCheckPeriod() {
- return getInteger("throttleCheckPeriod");
- }
-
- /**
- * Returns this index's total event count.
- *
- * @return This index's total event count.
- */
- public int getTotalEventCount() {
- return getInteger("totalEventCount");
- }
-
- /**
- * Returns whether or not this index is an internal index.
- *
- * @return Whether ot not this index is an internal index.
- */
- public boolean isInternal() {
- return getBoolean("isInternal");
- }
-
- /**
- * Performs rolling hot buckets for this index.
- */
- public void rollHotBuckets() {
- ResponseMessage response = service.post(path + "/roll-hot-buckets");
- assert(response.getStatus() == 200);
- }
-
- /**
- * Submits an event to this index through HTTP POST.
- *
- * @param data Event data posted.
- */
- public void submit(String data) {
- RequestMessage request = new RequestMessage("POST");
- request.setContent(data);
- service.send("receivers/simple?index=" + getName(), request);
- }
-
- /**
- * Uploads a file to this index as an event stream. Note: this file must
- * be directly accessible to the Splunk server.
- *
- * @param filename The file uploaded.
- */
- public void upload(String filename) {
- Args args = new Args();
- args.put("name", filename);
- args.put("index", getName());
- service.post("data/inputs/oneshot", args);
- }
-}
-
diff --git a/splunk/com/splunk/InputCollection.java b/splunk/com/splunk/InputCollection.java
deleted file mode 100644
index f0bf92f9..00000000
--- a/splunk/com/splunk/InputCollection.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a collection of inputs. The collection is heterogeneous
- * and each member contains a kind-property that indicates the specific
- * kind of input.
- */
-public class InputCollection extends EntityCollection {
- // CONSIDER: We can probably initialize the following based on platform and
- // avoid adding the Windows inputs to the list on non-Windows platforms.
- static InputKind[] kinds = new InputKind[] {
- InputKind.Monitor,
- InputKind.Script,
- InputKind.Tcp,
- InputKind.TcpSplunk,
- InputKind.Udp,
- InputKind.WindowsActiveDirectory,
- InputKind.WindowsEventLog,
- InputKind.WindowsPerfmon,
- InputKind.WindowsRegistry,
- InputKind.WindowsWmi
- };
-
- /**
- * Class constructor.
- *
- * @param service The connected service instance.
- */
- InputCollection(Service service) {
- super(service, "data/inputs");
- }
-
- /**
- * Create stub.
- *
- * @param name The name of the input.
- * @return no return.
- * @throws UnsupportedOperationException
- */
- @Override public Input create(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Create stub.
- *
- * @param name The name of the input.
- * @param args Optional arguments.
- * @return no return.
- * @throws UnsupportedOperationException
- */
- @Override public Input create(String name, Map args) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Creates a specific kind up input.
- *
- * @param name The name of the input created.
- * @param kind The specific kind of input created.
- * @param The implicit type of the input created.
- * @return The created input.
- */
- public T create(String name, InputKind kind) {
- return (T)create(name, kind, null);
- }
-
- /**
- * Creates a specific kind up input.
- *
- * @param name The name of the input created.
- * @param kind The specific kind of input created.
- * @param args Optional arguments.
- * @param The implicit type of the input created.
- * @return The created input.
- */
- public T
- create(String name, InputKind kind, Map args) {
- args = Args.create(args).add("name", name);
- String path = this.path + "/" + kind.relpath;
- service.post(path, args);
- invalidate();
- return (T)get(name);
- }
-
- /**
- * Create an Input resource item.
- *
- * @param entry The Atom object describing the entry.
- * @return the created input.
- */
- @Override protected Input createItem(AtomEntry entry) {
- String path = itemPath(entry);
- InputKind kind = itemKind(path);
- Class inputClass = kind.inputClass;
- return createItem(inputClass, path);
- }
-
- /**
- * Returns the the path's InputKind.
- *
- * @param path The input path.
- * @return The input kind.
- */
- protected InputKind itemKind(String path) {
- for (InputKind kind : kinds) {
- if (path.indexOf("data/inputs/" + kind.relpath) > 0)
- return kind;
- }
- return InputKind.Unknown; // Didn't recognize the input kind
- }
-
- /**
- * Refresh this input collection.
- *
- * @return The refreshed input collection.
- */
- @Override public InputCollection refresh() {
- items.clear();
-
- // Iterate over all input kinds and collect all instances.
- for (InputKind kind : kinds) {
- String relpath = kind.relpath;
- String inputs = String.format("%s/%s?count=-1", path, relpath);
- ResponseMessage response;
- try {
- response = service.get(inputs);
- }
- catch (HttpException e) {
- // On some platforms certain input endpoints don't exist, for
- // example the Windows inputs endpoints don't exist on non-
- // Windows platforms.
- if (e.getStatus() == 404) continue;
- throw e;
- }
- AtomFeed feed = AtomFeed.parse(response.getContent());
- load(feed);
- }
-
- return this;
- }
-}
-
diff --git a/splunk/com/splunk/InputKind.java b/splunk/com/splunk/InputKind.java
deleted file mode 100644
index 91146b45..00000000
--- a/splunk/com/splunk/InputKind.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Enumeration of the various Splunk input kinds.
- */
-public enum InputKind {
- /** Unknown input kind. */
- Unknown("Unknown", Input.class),
-
- /** {@code Monitor} input kind. */
- Monitor("monitor", MonitorInput.class),
-
- /** {@code Script} input kind. */
- Script("script", ScriptInput.class),
-
- /** {@code TCP} input kind, raw input data. */
- Tcp("tcp/raw", TcpInput.class),
-
- /** {@code TCP} input kind, processed input data. */
- TcpSplunk("tcp/cooked", TcpSplunkInput.class),
-
- /** {@code UDP} input kind. */
- Udp("udp", UdpInput.class),
-
- /** {@code Windows Active Directory} input kind. */
- WindowsActiveDirectory("ad", WindowsActiveDirectoryInput.class),
-
- /** {@code Windows Event Log} input kind. */
- WindowsEventLog("win-event-log-collections",WindowsEventLogInput.class),
-
- /** {@code Windows Perfmon} input kind. */
- WindowsPerfmon("win-perfmon", WindowsPerfmonInput.class),
-
- /** {@code Windows Registry} input kind. */
- WindowsRegistry("registry", WindowsRegistryInput.class),
-
- /** {@code Windows WMI} input kind. */
- WindowsWmi("win-wmi-collections", WindowsWmiInput.class);
-
- /**
- * Sets the active objects relative path and input class.
- *
- * @param relpath The relative path.
- * @param inputClass The input class.
- */
- InputKind(String relpath, Class inputClass) {
- this.relpath = relpath;
- this.inputClass = inputClass;
- }
-
- String relpath;
- Class inputClass;
-}
diff --git a/splunk/com/splunk/Job.java b/splunk/com/splunk/Job.java
deleted file mode 100644
index 9cd0840e..00000000
--- a/splunk/com/splunk/Job.java
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * Copyright 2011 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.InputStream;
-import java.util.Date;
-import java.util.Map;
-
-/**
- * Representation of a search job.
- */
-public class Job extends Entity {
-
- /**
- * Class constructor.
- *
- * @param service The connected service instance.
- * @param path The jobs search endpoint.
- */
- Job(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the action path.
- *
- * @param action Action requested.
- * @return The action path.
- */
- @Override protected String actionPath(String action) {
- if (action.equals("control"))
- return path + "/control";
- return super.actionPath(action);
- }
-
- /**
- * Performs the requested action on this job.
- *
- * @param action The action to perform
- * @return The job.
- */
- public Job control(String action) {
- return control(action, null);
- }
-
- /**
- * Performs the requested action on this job.
- *
- * @param action The action to perform.
- * @param args Optional arguments for this action.
- * @return The job.
- */
- public Job control(String action, Map args) {
- args = Args.create(args).add("action", action);
- service.post(actionPath("control"), args);
- invalidate();
- return this;
- }
-
- /**
- * Stops the current search and deletes the result cache.
- *
- * @return The job.
- */
- public Job cancel() {
- return control("cancel");
- }
-
- /**
- * Disables preview generation on this job.
- *
- * @return The job.
- */
- public Job disablePreview() {
- return control("disablepreview");
- }
-
- /**
- * Enables preview generation on this job (may slow search considerably).
- *
- * @return The job.
- */
- public Job enablePreview() {
- return control("enablepreview");
- }
-
- /**
- * Stops the search, and provides intermediate results available for
- * retrieval.
- *
- * @return The job.
- */
- public Job finish() {
- return control("finalize");
- }
-
- /**
- * Suspends the execution of the current search.
- *
- * @return The job.
- */
- public Job pause() {
- return control("pause");
- }
-
- /**
- * Returns this job's cursorTime attribute.
- *
- * @return This job's cursorTime attribute.
- */
- public Date getCursorTime() {
- return getDate("cursorTime");
- }
-
- /**
- * Returns this job's delegate attribute.
- *
- * @return This job's delegate attribute.
- */
- public String getDelegate() {
- return getString("delegate", null);
- }
-
- /**
- * Returns this job's disk usage, in bytes.
- *
- * @return This job's disk usage, in bytes.
- */
- public int getDiskUsage() {
- return getInteger("diskUsage");
- }
-
- /**
- * Returns this job's dispatch state. Valid values are from the set:
- * QUEUED, PARSING, RUNNING, PAUSED, FINALIZING, FAILED or DONE.
- *
- * @return This job's dispatch state.
- */
- public String getDispatchState() {
- return getString("dispatchState");
- }
-
- /**
- * Returns this job's progress, in the range of 0.0 to 1.0.
- *
- * @return This job's progress.
- */
- public float getDoneProgress() {
- return getFloat("doneProgress");
- }
-
- /**
- * Returns this job's dropCount attribute.
- *
- * @return This jobs dropCount attribute.
- */
- public int getDropCount() {
- return getInteger("dropCount");
- }
-
- /**
- * Returns this job's earliestTime attribute.
- *
- * @return This job's earlietTime attribute.
- */
- public Date getEarliestTime() {
- return getDate("earliestTime");
- }
-
- /**
- * Returns this job's eventAvailableCount attribute.
- *
- * @return This job's eventAvailableCount attribute.
- */
- public int getEventAvailableCount() {
- return getInteger("eventAvailableCount");
- }
-
- /**
- * Returns this job's number of events being returned.
- *
- * @return This job's number of events being returned.
- */
- public int getEventCount() {
- return getInteger("eventCount");
- }
-
- /**
- * Returns this job's eventFieldCount attribute.
- *
- * @return This job's eventFieldCount attribute.
- */
- public int getEventFieldCount() {
- return getInteger("eventFieldCount");
- }
-
- /**
- * Returns whether or not this job's event return is streaming.
- *
- * @return Whether or not this job's event return is streaming.
- */
- public boolean getEventIsStreaming() {
- return getBoolean("eventIsStreaming");
- }
-
- /**
- * Returns whether or not this job's event return is truncated.
- *
- * @return Whether or not this job's event return is truncated.
- */
- public boolean getEventIsTruncated() {
- return getBoolean("eventIsTruncated");
- }
-
- /**
- * Returns this job's event InputStream IO handle.
- *
- * @return This job's event InputStream IO handle.
- */
- public InputStream getEvents() {
- return getEvents(null);
- }
-
- /**
- * Returns this job's event InputStream IO handle.
- *
- * @param args Optional arguments to the event get.
- *
- * @return This job's event InputStream IO handle.
- */
- public InputStream getEvents(Map args) {
- ResponseMessage response = service.get(path + "/events", args);
- return response.getContent();
- }
-
- /**
- * Returns this job's original search query.
- *
- * @return This job's original search query.
- */
- public String getEventSearch() {
- return getString("eventSearch", null);
- }
-
- /**
- * Returns this job's eventSorting attribute.
- *
- * @return This job's eventSorting attribute.
- */
- public String getEventSorting() {
- return getString("eventSorting");
- }
-
- /**
- * Returns this job's keywords attribute.
- *
- * @return This job's keywords attribute.
- */
- public String getKeywords() {
- return getString("keywords", null);
- }
-
- /**
- * Returns this job's label.
- *
- * @return This job's label.
- */
- public String getLabel() {
- return getString("label", null);
- }
-
- /**
- * Returns this job's latestTime attribute.
- *
- * @return This job's latestTime attribute.
- */
- public Date getLatestTime() {
- return getDate("latestTime");
- }
-
- /**
- * Returns this job's name, or more aptly its SID.
- *
- * @return This job's name.
- */
- @Override public String getName() {
- return getSid();
- }
-
- /**
- * Returns this job's numPreviews attribute.
- *
- * @return This job's numPreviews attribute.
- */
- public int getNumPreviews() {
- return getInteger("numPreviews");
- }
-
- /**
- * Returns this job's priority in the range of 0-10.
- *
- * @return This job's priority.
- */
- public int getPriority() {
- return getInteger("priority");
- }
-
- /**
- * Sets this job's priority in the range of 0-10.
- *
- * @param value This job's new priority.
- */
- public void setPriority(int value) {
- control("setpriority", new Args("priority", value));
- }
-
- /**
- * Returns this job's remote search query string.
- *
- * @return This job's remote search query string.
- */
- public String getRemoteSearch() {
- return getString("remoteSearch", null);
- }
-
- /**
- * Returns this job's reportSearch attribute.
- *
- * @return This job's reportSearch attribute.
- */
- public String getReportSearch() {
- return getString("reportSearch", null);
- }
-
- /**
- * Returns this job's resultCount attribute.
- *
- * @return This job's resultCount attribute.
- */
- public int getResultCount() {
- return getInteger("resultCount");
- }
-
- /**
- * Returns whether or not this job's result is streaming.
- *
- * @return Whether or not this job's result is streaming.
- */
- public boolean getResultIsStreaming() {
- return getBoolean("resultIsStreaming");
- }
-
- /**
- * Returns this job's resultPreviewCount attribute.
- *
- * @return This job's resultPreviewCount attribute.
- */
- public int getResultPreviewCount() {
- return getInteger("resultPreviewCount");
- }
-
- /**
- * Returns this job's results InputStream IO handle.
- *
- * @return This job's results InputStream IO handle.
- */
- public InputStream getResults() {
- return getResults(null);
- }
-
- /**
- * Returns this job's results InputStream IO handle.
- *
- * @param args Optional arguments.
- * @return This job's results InputStream IO handle.
- */
- public InputStream getResults(Map args) {
- ResponseMessage response = service.get(path + "/results", args);
- return response.getContent();
- }
-
- /**
- * Returns this job's preview results InputStream IO handle.
- *
- * @return This job's preview results InputStream IO handle.
- */
- public InputStream getResultsPreview() {
- return getResultsPreview(null);
- }
-
- /**
- * Returns this job's preview results InputStream IO handle.
- *
- * @param args Optional arguments.
- * @return This job's preview results InputStream IO handle.
- */
- public InputStream getResultsPreview(Map args) {
- ResponseMessage response = service.get(path + "/results_preview", args);
- return response.getContent();
- }
-
- /**
- * Returns this job's run-time duration.
- *
- * @return This job's run-time duration.
- */
- public float getRunDuration() {
- return getFloat("runDuration");
- }
-
- /**
- * Returns this job's scanCount attribute.
- *
- * @return This job's scanCount attribute.
- */
- public int getScanCount() {
- return getInteger("scanCount");
- }
-
- /**
- * Returns this job's search title.
- *
- * @return This job's search title.
- */
- public String getSearch() {
- return getTitle();
- }
-
- /**
- * Returns this job's earliest search time.
- *
- * @return This job's earliest search time.
- */
- public String getSearchEarliestTime() {
- return getString("searchEarliestTime", null);
- }
-
- /**
- * Returns this job's latest search time.
- *
- * @return This job's latest search time.
- */
- public String getSearchLatestTime() {
- return getString("searchLatestTime", null);
- }
-
- /**
- * Returns this job's search log InputStream IO handle.
- *
- * @return This job's search log InputStream IO handle.
- */
- public InputStream getSearchLog() {
- return getSearchLog(null);
- }
-
- /**
- * Returns this job's search log InputStream IO handle.
- *
- * @param args Optional arguments
- * @return This job's search log InputStream IO handle.
- */
- public InputStream getSearchLog(Map args) {
- ResponseMessage response = service.get(path + "/search.log", args);
- return response.getContent();
- }
-
- /**
- * Returns this job's SID.
- *
- * @return This job's SID.
- */
- public String getSid() {
- return getString("sid");
- }
-
- /**
- * Returns this job's SID from within a response message
- *
- * @param response The response message.
- * @return This job's SID.
- */
- static String getSid(ResponseMessage response) {
- return Xml.parse(response.getContent())
- .getElementsByTagName("sid").item(0).getTextContent();
- }
-
- /**
- * Returns this jobs summary InputStream IO handle.
- *
- * @return This job's summary InputStream IO handle.
- */
- public InputStream getSummary() {
- return getSummary(null);
- }
-
- /**
- * Returns this jobs summary InputStream IO handle.
- *
- * @param args Optional arguments.
- * @return This job's summary InputStream IO handle.
- */
- public InputStream getSummary(Map args) {
- ResponseMessage response = service.get(path + "/summary", args);
- return response.getContent();
- }
-
- /**
- * Returns this job's statusBuckets attribute.
- *
- * @return This job's statusBuckets attribute.
- */
- public int getStatusBuckets() {
- return getInteger("statusBuckets");
- }
-
- /**
- * Returns this job's timeline InputStream IO handle.
- *
- * @return this job's timeline InputStream IO handle.
- */
- public InputStream getTimeline() {
- return getTimeline(null);
- }
-
- /**
- * Returns this job's timeline InputStream IO handle.
- *
- * @param args Optional arguments.
- * @return this job's timeline InputStream IO handle.
- */
- public InputStream getTimeline(Map args) {
- ResponseMessage response = service.get(path + "/timeline", args);
- return response.getContent();
- }
-
- /**
- * Returns this job's time-to-live.
- *
- * @return This job's time-to-live.
- */
- public int getTtl() {
- return getInteger("ttl");
- }
-
- /**
- * Returns whether or not this job is done.
- *
- * @return Whether or not this jobs is done.
- */
- public boolean isDone() {
- return getBoolean("isDone");
- }
-
- /**
- * Returns whether or not this job failed.
- *
- * @return Whether or not this job failed.
- */
- public boolean isFailed() {
- return getBoolean("isFailed");
- }
-
- /**
- * Returns whether or not this job is finalized.
- *
- * @return Whether or not this jobs is finalized.
- */
- public boolean isFinalized() {
- return getBoolean("isFinalized");
- }
-
- /**
- * Returns whether or not this jobs is paused.
- *
- * @return Whether or not this jobs is paused.
- */
- public boolean isPaused() {
- return getBoolean("isPaused");
- }
-
- /**
- * Returns whether or not this job's preview is enabled.
- *
- * @return Whether or not this job's preview is enabled.
- */
- public boolean isPreviewEnabled() {
- return getBoolean("isPreviewEnabled");
- }
-
- /**
- * Returns whether or not this job is a real time search.
- *
- * @return Whether or not this job is a real time search.
- */
- public boolean isRealTimeSearch() {
- return getBoolean("isRealTimeSearch");
- }
-
- /**
- * Returns whether or not this job has a remote timeline component.
- *
- * @return whether or not this job has a remote timeline component.
- */
- public boolean isRemoteTimeline() {
- return getBoolean("isRemoteTimeline");
- }
-
- /**
- * Returns this job's isSaved attribute.
- *
- * @return this job's isSaved attribute.
- */
- public boolean isSaved() {
- return getBoolean("isSaved");
- }
-
- /**
- * Return whether or not this search is a saved-search.
- *
- * @return Whether or not this search is a saved-search.
- */
- public boolean isSavedSearch() {
- return getBoolean("isSavedSearch");
- }
-
- /**
- * returns this job's isZombie attribute.
- *
- * @return Thsi job's isZombie attribute.
- */
- public boolean isZombie() {
- return getBoolean("isZombie");
- }
-
- // Job "entities" don't return an AtomFeed, only an AtomEntry.
-
- /**
- * Refresh this job.
- *
- * @return This job.
- */
- @Override public Job refresh() {
- ResponseMessage response = service.get(path);
- AtomEntry entry = AtomEntry.parse(response.getContent());
- load(entry);
- return this;
- }
-
- /**
- * Removes this job; which is unsupported and will throw an exception.
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-}
-
diff --git a/splunk/com/splunk/JobCollection.java b/splunk/com/splunk/JobCollection.java
deleted file mode 100644
index 85e3da50..00000000
--- a/splunk/com/splunk/JobCollection.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a collection of jobs.
- */
-public class JobCollection extends EntityCollection {
- static String oneShotNotAllowed = String.format(
- "Oneshot not allowed, use service oneShotSearch method");
-
- /**
- * Class constructor.
- *
- * @param service The connected service instance.
- */
- JobCollection(Service service) {
- super(service, "search/jobs", Job.class);
- }
-
- /**
- * Creates a search job with a UTF8 pre-encoded search request. Note that
- * a 'oneshot' request is invalid here. Please use the createOneShot method
- * instead.
- *
- * @param query The search query string.
- * @return The search job SID.
- */
- public Job create(String query) {
- return create(query, null);
- }
-
- /**
- * Creates a search job. Note that a 'oneshot' request is invalid here.
- * Please use the createOneShot method instead.
- *
- * @param query The search query.
- * @param args The arguments supplied to this job's creation.
- * @return The search job 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);
- invalidate();
- String sid = Job.getSid(response);
- return get(sid);
- }
-
- /**
- * Returns this job's response.
- *
- * @return This job's response.
- */
- @Override public ResponseMessage list() {
- return service.get(path + "?count=0");
- }
-
- /**
- * Returns this job's SID. The SID is used as this item's key.
- *
- * @param entry The Atom response.
- * @return This job's SID.
- */
- @Override protected String itemKey(AtomEntry entry) {
- return (String)entry.content.get("sid");
- }
-}
diff --git a/splunk/com/splunk/License.java b/splunk/com/splunk/License.java
deleted file mode 100644
index 325b1ca7..00000000
--- a/splunk/com/splunk/License.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 2011 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.Date;
-
-/**
- * Representation of a license.
- */
-public class License extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The license endpoint.
- */
- License(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this license's creation time.
- *
- * @return This license's creation time.
- */
- public Date getCreationTime() {
- return getDateFromEpoch("creation_time");
- }
-
- /**
- * Returns this license's expiration time.
- *
- * @return This license's expiration time.
- */
- public Date getExpirationTime() {
- return getDateFromEpoch("expiration_time");
- }
-
- /**
- * Returns this license's list of enabled features.
- *
- * @return This license's list of enabled features.
- */
- public String[] getFeatures() {
- return getStringArray("features");
- }
-
- /**
- * Returns this license's group ID, or null if not available.
- *
- * @return This license's group ID.
- */
- public String getGroupId() {
- return getString("group_id", null);
- }
-
- /**
- * Returns this license's label, or null if not available.
- *
- * @return This license's label.
- */
- public String getLabel() {
- return getString("label", null);
- }
-
- /**
- * Returns this license's hash value.
- *
- * @return This license's hash value.
- */
- public String getLicenseHash() {
- return getString("license_hash");
- }
-
- /**
- * Returns this license's maximum violation value.
- *
- * @return This license's maximum violation value.
- */
- public int getMaxViolations() {
- return getInteger("max_violations");
- }
-
- /**
- * Returns this license's ingest data quota.
- *
- * @return This license's ingest data quota.
- */
- public long getQuota() {
- return getByteCount("quota");
- }
-
- /**
- * Returns this license's sourcetypes, or null if not specified.
- *
- * @return This license's sourcetypes.
- */
- public String[] getSourceTypes() {
- return getStringArray("sourcetypes", null);
- }
-
- /**
- * Returns this license's stack ID.
- *
- * @return This license's stack ID.
- */
- public String getStackId() {
- return getString("stack_id");
- }
-
- /**
- * Returns this license's status.
- *
- * @return This license's status.
- */
- public String getStatus() {
- return getString("status");
- }
-
- /**
- * Returns this license's type.
- *
- * @return This license's type.
- */
- public String getType() {
- return getString("type");
- }
-
- /**
- * Returns this license's window period.
- *
- * @return This license's window period.
- */
- public int getWindowPeriod() {
- return getInteger("window_period");
- }
-}
-
diff --git a/splunk/com/splunk/LicensePool.java b/splunk/com/splunk/LicensePool.java
deleted file mode 100644
index 1d7afe1b..00000000
--- a/splunk/com/splunk/LicensePool.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a license pool.
- */
-public class LicensePool extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The license group endpoint.
- */
- LicensePool(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this license pool's description, or null if not specified.
- *
- * @return This license pool's description.
- */
- public String getDescription() {
- return getString("description", null);
- }
-
- /**
- * Returns this license pool's ingest quota, in bytes. Note: the return
- * type is a string, because the value can also be a literal "MAX".
- *
- * @return This license pool's data ingest quota.
- */
- public String getQuota() {
- return getString("quota", "0");
- }
-
- /**
- * Returns this license pool's list of slaves, or null if not specified.
- *
- * @return This license pool's list of slaves.
- */
- public String[] getSlaves() {
- return getStringArray("slaves", null);
- }
-
- /**
- * Returns this license pool's slave bytes used.
- *
- * @return This license pool's slave bytes used.
- */
- public long getSlavesUsageBytes() {
- return getLong("salves_usage_bytes", 0);
- }
-
- /**
- * Returns this license pool's stack ID, or null if not specified. The valid
- * values are download-trial, enterprise, forwarder, or free.
- *
- * @return This license pool's stack ID.
- */
- public String getStackId() {
- return getString("stack_id", null);
- }
-
- /**
- * Returns this license pool's used bytes.
- *
- * @return This license pool's used bytes.
- */
- public long getUsedBytes() {
- return getLong("used_bytes", 0);
- }
-}
diff --git a/splunk/com/splunk/LicensePoolCollection.java b/splunk/com/splunk/LicensePoolCollection.java
deleted file mode 100644
index 0a8d3f15..00000000
--- a/splunk/com/splunk/LicensePoolCollection.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a collection of license pools.
- */
-public class LicensePoolCollection extends EntityCollection {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- */
- LicensePoolCollection(Service service) {
- super(service, "licenser/pools", LicensePool.class);
- }
-
- /**
- * Creates a license pool.
- *
- * Quota can be MAX (Only one pool can use MAX size), a number or a number
- * followed by MB or GB.
- *
- * @param name The name of this new license pool.
- * @param quota The quota in bytes of this license pool.
- * @param stackId The stack ID corresponding to this license pool.
- * @return The new license pool.
- */
- public LicensePool create(String name, int quota, String stackId) {
- return create(name, quota, stackId, null);
- }
-
- /**
- * Creates a license pool.
- *
- * Quota can be MAX (Only one pool can use MAX size), a number or a number
- * followed by MB or GB.
- *
- * @param name The name of this new license pool.
- * @param quota The quota in bytes of this license pool.
- * @param stackId The stack ID corresponding to this license pool.
- * @param args Optional arguments.
- * @return The new license pool.
- */
- public LicensePool
- create(String name, int quota, String stackId, Map args) {
- args = Args.create(args);
- args.put("quota", quota);
- args.put("stack_id", stackId);
- return create(name, args);
- }
-}
diff --git a/splunk/com/splunk/MonitorInput.java b/splunk/com/splunk/MonitorInput.java
deleted file mode 100644
index 651b7351..00000000
--- a/splunk/com/splunk/MonitorInput.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a monitor input.
- */
-public class MonitorInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The monitor input endpoint.
- */
- MonitorInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this monitor input's filecount.
- *
- * @return This monitor input's filecount.
- */
- public int getFileCount() {
- return getInteger("filecount", -1);
- }
-
- /**
- * Returns this monitor input's host, or null if not specified.
- *
- * @return This monitor input's host.
- */
- public String getHost() {
- return getString("host", null);
- }
-
- /**
- * Returns this monitor input's index name.
- *
- * @return This monitor input's index name.
- */
- public String getIndex() {
- return getString("index");
- }
-
- /**
- * Returns the monitor input kind.
- *
- * @return The monitor input kind.
- */
- public InputKind getKind() {
- return InputKind.Monitor;
- }
-
- /**
- * Returns this monitor input's _rcvbuf attribute.
- *
- * @return This monitor input's _rcvbuf attribute.
- */
- public int getRcvBuf() {
- return getInteger("_rcvbuf");
- }
-}
diff --git a/splunk/com/splunk/OutputDefault.java b/splunk/com/splunk/OutputDefault.java
deleted file mode 100644
index 4d2647b9..00000000
--- a/splunk/com/splunk/OutputDefault.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of the default TCP output configuration.
- */
-public class OutputDefault extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- */
- OutputDefault(Service service) {
- super(service, "data/outputs/tcp/default");
- }
-
- /**
- * Returns whether or not this forwarded performs automatic load balancing.
- * When true, this forwarder selects a new indexer every autoLBFrequency
- * seconds, or immediately when an open connection to an indexer is lost.
- *
- * @return Whether or not this forwarder performs automatic load balancing.
- */
- public boolean autoLb() {
- return getBoolean("autoLB");
- }
-
- /**
- * Returns whether or not this forwarder will block. If set to false, events
- * will get thrown away if no indexers in the group are reachable.
- *
- * @return Whether or not this forwarder will block.
- */
- public boolean blockOnQueueFull() {
- return getBoolean("blockOnQueueFull", true);
- }
-
- /**
- * Returns this forwarder's auto load balancing frequency, or -1 if not
- * specified.
- *
- * @return this forwards auto load balancing frequency.
- */
- public int getAutoLbFrequency() {
- return getInteger("autoLBFrequency", -1);
- }
-
- /**
- * Returns this forwarder's default group as a comma separated list, or null
- * if not specified. After Splunk 4.2, this attribute is no longer required.
- *
- * @return this forwarder's default group list.
- */
- public String getDefaultGroup() {
- return getString("defaultGroup", null);
- }
-
- /**
- * Returns the number of second this forwarder's waits before throwing out
- * events if the output queue is full. A setting of 0 or -1 causes this
- * forwarder to block.
- *
- * @return this forwards wait time, in seconds, before events are dropped
- * under queue full conditions.
- */
- public int getDropEventsOnQueueFull() {
- return getInteger("dropEventsOnQueueFull", -1);
- }
-
- /**
- * Returns this forwarder's inclusive set of indexes.
- *
- * @return This forwarder's inclusive set of indexes.
- */
- public String getForwardedIndex0Whitelist() {
- return getString("forwardedindex.0.whitelist");
- }
-
- /**
- * Returns this forwarder's exclusive set of indexes.
- *
- * @return This forwarder's exclusive set of indexes.
- */
- public String getForwardedIndex1Blacklist() {
- return getString("forwardedindex.1.blacklist");
- }
-
- /**
- * Returns this forwarder's inclusive set of indexes.
- *
- * @return This forwarder's inclusive set of indexes.
- */
- public String getForwardedIndex2Whitelist() {
- return getString("forwardedindex.2.whitelist");
- }
-
- /**
- * Returns this forwarder's heartbeat frequency sent to the indexer. Note
- * that this field is only used if sendCookedData is set to true.
- *
- * @return This forwarder's heartbeat frequency.
- */
- public int getHeartbeatFrequency() {
- return getInteger("heartbeatFrequency", 30);
- }
-
- /**
- * Returns this forwarder's outbound event queue's maximum size, in bytes.
- * Implicitly this forwarder's wait queue is 3 times this value.
- *
- * @return This forwarder's output event queue's maximum size.
- */
- public long getMaxQueueSize() {
- return getByteCount("maxQueueSize");
- }
-
- /**
- * Returns whether or not to index data locally in addition to forwarding.
- * This setting is not available for light forwarders.
- *
- * @return Whether or not to index data locally in addition to forarding.
- */
- public boolean indexAndForward() {
- return getBoolean("indexAndForward", false);
- }
-
- /**
- * Returns whether or not this forwarder sends compressed data.
- *
- * @return Whether or not this forwarder sends compressed data.
- */
- public boolean isCompressed() {
- return getBoolean("compressed", false);
- }
-
- /**
- * Returns whether or not this forwarder's index filter is disabled.
- *
- * @return Whether or not this forwarder's index filter is disabled.
- */
- public boolean isForwardedIndexFilterDisable() {
- return getBoolean("forwardedindex.filter.disable");
- }
-
- /**
- * Returns whether or not the event data has been processed by Splunk.
- *
- * @return Whether ot nor the event data has been processed by Splunk.
- */
- public boolean sendCookedData() {
- return getBoolean("sendCookedData", true);
- }
-}
diff --git a/splunk/com/splunk/OutputGroup.java b/splunk/com/splunk/OutputGroup.java
deleted file mode 100644
index fb9906fe..00000000
--- a/splunk/com/splunk/OutputGroup.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of an output group.
- */
-public class OutputGroup extends Entity {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The output group endpoint.
- */
- OutputGroup(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this forwarder's group output processor. Valid values are from
- * the set tcpout, syslog, httpout.
- *
- * @return This forwarder's group output processor.
- */
- public String getMethod() {
- return getString("method", null);
- }
-
- /**
- * Returns this forwarder group's server list.
- *
- * @return This forwarder group's server list.
- */
- public String[] getServers() {
- return getStringArray("servers");
- }
-}
diff --git a/splunk/com/splunk/PasswordCollection.java b/splunk/com/splunk/PasswordCollection.java
deleted file mode 100644
index 44dfad90..00000000
--- a/splunk/com/splunk/PasswordCollection.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a collection of passwords.
- */
-public class PasswordCollection extends EntityCollection {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- */
- PasswordCollection(Service service) {
- // Starting with 4.3 this is available at "storage/passwords"
- super(service, "admin/passwords", Password.class);
- }
-
- /**
- * Creates a credential.
- *
- * @param name The username to be created.
- * @param password The password associated with this username.
- *
- * @return The new credential.
- */
- public Password create(String name, String password) {
- Args args = new Args("password", password);
- return create(name, args);
- }
-
- /**
- * Creates a credential.
- *
- * @param name The username to be created.
- * @param password The password associated with this username.
- * @param realm The credential realm.
- *
- * @return The new credential.
- */
- public Password create(String name, String password, String realm) {
- Args args = new Args();
- args.put("password", password);
- args.put("realm", realm);
- return create(name, args);
- }
-
- // Passwords user the username as a key.
-
- /**
- * Returns the username
- *
- * @param entry The Atom object describing the credential.
- * @return The username.
- */
- @Override protected String itemKey(AtomEntry entry) {
- return (String)entry.content.get("username");
- }
-}
diff --git a/splunk/com/splunk/Resource.java b/splunk/com/splunk/Resource.java
deleted file mode 100644
index c5514c43..00000000
--- a/splunk/com/splunk/Resource.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a Splunk resource.
- */
-public abstract class Resource {
- protected Map actions;
- protected String path;
- protected Service service;
- protected String title;
- private boolean maybeValid = false;
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The target endpoint.
- */
- Resource(Service service, String path) {
- this.path = service.fullpath(path);
- this.service = service;
- }
-
- /**
- * Returns a map of actions that are enabled for this resource.
- *
- * @return Action map.
- */
- public Map getActions() {
- return validate().actions;
- }
-
- /**
- * Returns the resource name. Every resource has a name, which by default
- * is its title. That name may also be used as the key for the resources
- * if it belongs to a container resource, as in the case of an entity that
- * belongs to an entity collection.
- *
- * @return Resource namne.
- */
- //
- public String getName() {
- return getTitle();
- }
-
- /**
- * Returns the path to this resource.
- *
- * @return Resource path.
- */
- public String getPath() {
- return this.path;
- }
-
- /**
- * Returns the service instance this resource instance is affiliated with.
- *
- * @return Service instance.
- */
- public Service getService() {
- return this.service;
- }
-
- /**
- * Return the title of this resource. This corresponds to the Atom title
- * element return in the Splunk REST API.
- *
- * @return Resource title.
- */
- public String getTitle() {
- return validate().title;
- }
-
- /**
- * Set the title of this resource.
- *
- * @param value Resource title.
- */
- void setTitle(String value) {
- this.title = value;
- }
-
- /**
- * Mark the local state of this resource instance as no longer current.
- *
- * @return The current resource instance.
- */
- public Resource invalidate() {
- this.maybeValid = false;
- return this;
- }
-
- /**
- * Load the state of this resource instance from the given Atom object.
- *
- * @param value Atom object to load resources state from.
- * @return The current resource instance.
- */
- Resource load(AtomObject value) {
- if (value == null) {
- this.title = "title";
- }
- else {
- this.actions = value.links;
- this.title = value.title;
- }
- this.maybeValid = true;
- return this;
- }
-
- /**
- * Refresh the local state of this resource instance.
- *
- * @return The current resource instance.
- */
- public abstract Resource refresh();
-
- /**
- * Ensure that the local state of the resource instance is current,
- * possibly invoking {@code refresh} if necessarry.
- *
- * @return The current resource instance.
- */
- public Resource validate() {
- if (this.maybeValid == false) refresh();
- return this;
- }
-}
diff --git a/splunk/com/splunk/ResourceCollection.java b/splunk/com/splunk/ResourceCollection.java
deleted file mode 100644
index a7487c87..00000000
--- a/splunk/com/splunk/ResourceCollection.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2011 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.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Representation of a collection of Splunk resources.
- *
- * @param The type of members of the collection.
- */
-public class ResourceCollection
- extends Resource implements Map
-{
- protected Map items = new HashMap();
- protected Class itemClass;
-
- ResourceCollection(Service service, String path, Class itemClass) {
- super(service, path);
- this.itemClass = itemClass;
- }
-
- /** {@inheritDoc} */
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- public boolean containsKey(Object key) {
- return validate().items.containsKey(key);
- }
-
- /** {@inheritDoc} */
- public boolean containsValue(Object value) {
- return validate().items.containsValue(value);
- }
-
- static Class[] itemSig = new Class[] { Service.class, String.class };
-
- /**
- * Creates a collection member (aka item).
- *
- * @param itemClass Class of the member to create.
- * @param path Path to the member resource.
- * @return The created member.
- */
- protected T createItem(Class itemClass, String path) {
- Constructor ctor;
- try {
- ctor = itemClass.getDeclaredConstructor(itemSig);
- }
- catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
-
- T item;
- try {
- item = (T)ctor.newInstance(service, path);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- catch (InstantiationException e) {
- throw new RuntimeException(e);
- }
-
- return item;
- }
-
- /**
- * Creates a collection member corresponding to the given Atom entry.
- * This base implementation uses the class object pass in when the generic
- * ResourceCollection was created. Subclasses may override this method
- * to provide alternative means of instantiating collection items.
- *
- * @param entry Atom entry corresponding to the member to instantiate.
- * @return The newly created member.
- */
- protected T createItem(AtomEntry entry) {
- return createItem(itemClass, itemPath(entry));
- }
-
- /** {@inheritDoc} */
- public Set> entrySet() {
- return validate().items.entrySet();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- return validate().items.equals(o);
- }
-
- /** {@inheritDoc} */
- public T get(Object key) {
- return validate().items.get(key);
- }
-
- @Override public int hashCode() {
- return validate().items.hashCode();
- }
-
- /** {@inheritDoc} */
- public boolean isEmpty() {
- return validate().items.isEmpty();
- }
-
- /**
- * Returns the value to use as the item key from the given Atom entry.
- * Subclasses may override this for collections that use something other
- * than title as the key.
- *
- * @param entry The Atom entry corresponding to the collection member.
- * @return The value to use as the member's key.
- */
- protected String itemKey(AtomEntry entry) {
- return entry.title;
- }
-
- /**
- * Returns the vlaue to use as the item path from the given Atom entry.
- * Subclasses may override this to support alternative methods of
- * determining a members path.
- *
- * @param entry The Atom entry corresponding to the collection member.
- * @return The value to use as the members path.
- */
- protected String itemPath(AtomEntry entry) {
- return entry.links.get("alternate");
- }
-
- /** {@inheritDoc} */
- public Set keySet() {
- return validate().items.keySet();
- }
-
- /**
- * Issues an HTTP request to list the contents of the collection resource.
- *
- * @return List response message.
- */
- public ResponseMessage list() {
- return service.get(path + "?count=-1");
- }
-
- /**
- * Loads the collection resource from the given {@code AtomFeed}.
- *
- * @param value The {@code AtomFeed} instance to load the collection from.
- * @return The current resource collection instance.
- */
- ResourceCollection load(AtomFeed value) {
- super.load(value);
- for (AtomEntry entry : value.entries) {
- String key = itemKey(entry);
- T item = createItem(entry);
- items.put(key, item);
- }
- return this;
- }
-
- /** {@inheritDoc} */
- public T put(String key, T value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Copies all mappings from the given map to this map (unsupported).
- *
- * @param map The set of mappings to copy into this map.
- */
- public void putAll(Map extends String, ? extends T> map) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public ResourceCollection refresh() {
- items.clear();
- ResponseMessage response = list();
- assert(response.getStatus() == 200);
- AtomFeed feed = AtomFeed.parse(response.getContent());
- load(feed);
- return this;
- }
-
- /** {@inheritDoc} */
- public T remove(Object key) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- public int size() {
- return validate().items.size();
- }
-
- /** {@inheritDoc} */
- @Override public ResourceCollection validate() {
- super.validate();
- return this;
- }
-
- /** {@inheritDoc} */
- public Collection values() {
- return validate().items.values();
- }
-}
diff --git a/splunk/com/splunk/Role.java b/splunk/com/splunk/Role.java
deleted file mode 100644
index 532f57c8..00000000
--- a/splunk/com/splunk/Role.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk role.
- */
-public class Role extends Entity {
-
- /**
- * Constructs an instance of the Role entity.
- *
- * @param service The service the entity is affiliated with.
- * @param path The resource path.
- */
- Role(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns an array of capabilities assigned to this role.
- *
- * @return Array of capabilities.
- */
- public String[] getCapabilities() {
- return getStringArray("capabilities");
- }
-
- /**
- * Returns the name of the app to use as the default for this role.
- *
- * @return The default app for this role.
- */
- public String getDefaultApp() {
- return getString("defaultApp", null);
- }
-
- /**
- * Returns an array of capabilities imported for this role.
- *
- * @return Array of imported capabilities.
- */
- public String[] getImportedCapabilities() {
- return getStringArray("imported_capabilities", null);
- }
-
- /**
- * Returns an array of roles used to import attributes from.
- *
- * @return Array of roles imported from.
- */
- public String[] getImportedRoles() {
- return getStringArray("imported_roles", null);
- }
-
- /**
- * Returns the imported real time search jobs quota.
- *
- * @return Imported real time search jobs quota.
- */
- public int getImportedRtSearchJobsQuota() {
- return getInteger("imported_rtSrchJobsQuota");
- }
-
- /**
- * Returns the imported search disk quota.
- *
- * @return Imported serach disk quota.
- */
- public int getImportedSearchDiskQuota() {
- return getInteger("imported_srchDiskQuota");
- }
-
- /**
- * Returns the imported search filter.
- *
- * @return Imported search filter.
- */
- public String getImportedSearchFilter() {
- return getString("imported_srchFilter", null);
- }
-
- /**
- * Returns an array of imported allowed indexes.
- *
- * @return Array of imported allowed indexes.
- */
- public String[] getImportedIndexesAllowed() {
- return getStringArray("imported_srchIndexesAllowed", null);
- }
-
- /**
- * Returns an array of imported default indexes.
- *
- * @return Array of imported default indexes.
- */
- public String[] getImportedIndexesDefault() {
- return getStringArray("imported_srchIndexesDefault", null);
- }
-
- /**
- * Returns the imported normal search jobs quota.
- *
- * @return The imported normal search jobs quota.
- */
- public int getImportedSearchJobsQuota() {
- return getInteger("imported_srchJobsQuota");
- }
-
- /**
- * Returns the maximum number of concurrent real time search jobs allowed
- * for this role.
- *
- * @return Maximum number of concurrent real time search jobs.
- */
- public int getRtSearchJobsQuota() {
- return getInteger("rtSrchJobsQuota");
- }
-
- /**
- * Returns the maximum disk space in MB that can be used by a users in
- * this role.
- *
- * @return Maximum disk space usage for this role.
- */
- public int getSearchDiskQuota() {
- return getInteger("srchDiskQuota");
- }
-
- /**
- * Returns a search string that restricts the scope of searches run by
- * users in this role.
- *
- * @return Search string that restrics scope of searches.
- */
- public String getSearchFilter() {
- return getString("srchFilter", null);
- }
-
- /**
- * Returns an array of indexes that the role has permission to search.
- *
- * @return Array of indexes the role has permission to search.
- */
- public String[] getSearchIndexesAllowed() {
- return getStringArray("srchIndexesAllowed", null);
- }
-
- /**
- * Returns an array of default indexes to search when no index is specified.
- *
- * @return An array of default indexes to search when none is specified.
- */
- public String[] getSearchIndexesDefault() {
- return getStringArray("srchIndexesDefault", null);
- }
-
- /**
- * Returns the maximum number of concurrently running normal searches jobs
- * allowed for users in this role.
- *
- * @return Maximum number of concurrent normal search jobs.
- */
- public int getSearchJobsQuota() {
- return getInteger("srchJobsQuota");
- }
-
- /**
- * Returns the maximum time span of a search, in seconds, for users in this
- * role.
- *
- * @return Maximum time span of a search, in seconds.
- */
- public int getSearchTimeWin() {
- return getInteger("srchTimeWin");
- }
-}
diff --git a/splunk/com/splunk/SavedSearch.java b/splunk/com/splunk/SavedSearch.java
deleted file mode 100644
index 8e40c14c..00000000
--- a/splunk/com/splunk/SavedSearch.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a saved search.
- */
-public class SavedSearch extends Entity {
-
- /**
- * Constructs an instance of the SavedSearch entity.
- *
- * @param service The service the entity is affiliated with.
- * @param path The resource path.
- */
- SavedSearch(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Acknowledge the suppression of alerts from this saved search and resume
- * alerting.
- */
- public void acknowledge() {
- service.post(actionPath("acknowledge"));
- invalidate();
- }
-
- /** {@inheritDoc} */
- @Override protected String actionPath(String action) {
- if (action.equals("acknowledge"))
- return path + "/acknowledge";
- if (action.equals("dispatch"))
- return path + "/dispatch";
- if (action.equals("history"))
- return path + "/history";
- return super.actionPath(action);
- }
-
- /**
- * Dispatch (execute) the saved search.
- *
- * @return The search job.
- */
- public Job dispatch() {
- return dispatch(null);
- }
-
- /**
- * Dispatch (execute) the saved search using the given dispatch args.
- *
- * @param args Dispatch arguments.
- * @return The search job.
- */
- // CONSIDER: We should take an optional maxWait argument
- // CONSIDER: Another alternative is to return a MaybeJob object that
- // has an "exists" property, so the user can call maybeJob.refresh()
- // until exists == true.
- public Job dispatch(Map args) {
- ResponseMessage response = service.post(actionPath("dispatch"), args);
- invalidate();
- String sid = Job.getSid(response);
-
- // The sad fact here is that the search job does not immediately show
- // up once the saved search is dispatched, and we may therefore have
- // to wait a while in order to return the search job.
-
- Job job = null;
- JobCollection jobs = service.getJobs();
- for (int retry = 5; retry > 0; --retry) {
- jobs.refresh();
- job = jobs.get(sid);
- if (job != null) break;
- try { Thread.sleep(1000); }
- catch (InterruptedException e) {};
- }
-
- return job;
- }
-
- /**
- * Returns an array of search jobs created from this saved search.
- *
- * @return An array of search jobs created from this saved search.
- */
- public Job[] history() {
- ResponseMessage response = service.get(actionPath("history"));
- AtomFeed feed = AtomFeed.parse(response.getContent());
- 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, "search/jobs/" + sid);
- }
- return result;
- }
-
- /**
- * Answers if search results are attached to an email.
- *
- * @return Answer if search results are attached to an email.
- */
- public String getActionEmailSendResults() {
- return getString("action.email.sendresults", null);
- }
-
- /**
- * Returns a semicolon delimited list of email recipients.
- *
- * @return Semicolon delimited list of email recipients.
- */
- public String getActionEmailTo() {
- return getString("action.email.to", null);
- }
-
- /**
- * Returns the period of time to show the alert in the dashboard.
- *
- * @return The period of time to show the alert in the dashboard.
- */
- public String getAlertExpires() {
- return getString("alert.expires");
- }
-
- /**
- * Returns the alert severity level.
- *
- * @return The alert severity level.
- */
- public int getAlertSeverity() {
- return getInteger("alert.severity");
- }
-
- /**
- * Answers if alert suppression is enabled for this search.
- *
- * @return Answer if alert suppression is enabled for this search.
- */
- public String getAlertSuppress() {
- return getString("alert.suppress", null);
- }
-
- /**
- * Returns the alert suppression period.
- *
- * @return The alert suppression period.
- */
- public String getAlertSuppressPeriod() {
- return getString("alert.suppress.period", null);
- }
-
- /**
- * Returns alert tracking setting.
- *
- * @return Returns alert tracking setting.
- */
- public String getAlertTrack() {
- return getString("alert.track");
- }
-
- /**
- * Returns the alert comparator.
- *
- * @return The alert comparator.
- */
- public String getAlertComparator() {
- return getString("alert_comparator", null);
- }
-
- /**
- * Returns a conditional search that is evaluated against the results of
- * the saved search, defaults to empty.
- *
- * @return A conditional search used against the results of the saved
- * search.
- */
- public String getAlertCondition() {
- return getString("alert_condition", null);
- }
-
- /**
- * Returns the value to compare to before triggering the alert action.
- *
- * @return The alert threashold value.
- */
- public String getAlertThreshold() {
- return getString("alert_threshold", null);
- }
-
- /**
- * Returns what to base the alert on, overridden by {@code alert_condition}.
- * Valid values are: always, custom, number of events, number of hosts and
- * number of sources.
- *
- * @return The alert type.
- */
- public String getAlertType() {
- return getString("alert_type");
- }
-
- /**
- * Returns the cron schedule for executing this saved search.
- *
- * @return The cron schedule for this saved search.
- */
- public String getCronSchedule() {
- return getString("cron_schedule", null);
- }
-
- /**
- * Returns a human readable description of this saved search, defaults to
- * empty.
- *
- * @return A description of this saved search.
- */
- public String getDescription() {
- return getString("description", null);
- }
-
- /**
- * Returns the maximum number of timeline buckets.
- *
- * @return The maximum number of timeline buckets.
- */
- public int getDispatchBuckets() {
- return getInteger("dispatch.buckets");
- }
-
- /**
- * Returns the earliest time for this search.
- *
- * @return The earliest time for this search.
- */
- public String getDispatchEarliestTime() {
- return getString("dispatch.earliest_time", null);
- }
-
- /**
- * Returns the latest time for this search.
- *
- * @return The latest time for this search.
- */
- public String getDispatchLatestTime() {
- return getString("dispatch.latest_time", null);
- }
-
- /**
- * Answers if lookups are enabled for this search.
- *
- * @return {@code true} if lookups are enabled.
- */
- public boolean getDispatchLookups() {
- return getBoolean("dispatch.lookups");
- }
-
-
- /**
- * Returns the maximum number of results before finalizing the search.
- *
- * @return The maximum number of results before finalizing the search.
- */
- public int getDispatchMaxCount() {
- return getInteger("dispatch.max_count");
- }
-
- /**
- * Returns the maximum amount of time (in seconds) before finalizing the
- * search.
- *
- * @return The maximum amount of time before finalizing the search.
- */
- public String getDispatchMaxTime() {
- return getString("dispatch.max_time");
- }
-
- /**
- * Returns how frequently Splunk should run the reduce phase on accumulated
- * map values.
- *
- * @return Frequency Splunk should run the reduce phase on accumulated
- * map values.
- */
- public int getDispatchReduceFreq() {
- return getInteger("dispatch.reduce_freq");
- }
-
- /**
- * Answers if Splunk spawns a new search process when this saved search
- * is executed.
- *
- * @return {@code true} if Splunk spawns a new process when this saved
- * search is executed.
- */
- public boolean getDispatchSpawnProcess() {
- return getBoolean("dispatch.spawn_process");
- }
-
- /**
- * Returns the time format used to specify the earliest and latest times
- * for this search.
- *
- * @return The time format used to specify the earliest and latest times
- * for this search.
- */
- public String getDispatchTimeFormat() {
- return getString("dispatch.time_format");
- }
-
- /**
- * Returns the time to live (in seconds) for artifacts of the scheduled
- * search, if no alerts are triggered.
- *
- * @return The time to live for artifacts of the scheduled search.
- */
- public String getDispatchTtl() {
- return getString("dispatch.ttl");
- }
-
- /**
- * Returns the default UI view in which to load results
- *
- * @return The default UI view in which to load results.
- */
- public String getDisplayView() {
- return getString("displayview", null);
- }
-
- /**
- * The maximum number of concurrent instances of this search the scheduler
- * is allowed to run.
- *
- * @return Maximum number of concurrent instances of this search allowed.
- */
- public int getMaxConcurrent() {
- return getInteger("max_concurrent");
- }
-
- /**
- * Returns the method used by the scheduler to compute the next execution
- * time of a scheduled search.
- *
- * @return The method for computing the next execution time of a scheduled
- * search.
- */
- public boolean getRealtimeSchedule() {
- return getBoolean("realtime_schedule");
- }
-
- /**
- * Returns the app this search should be dispatched in.
- *
- * @return the app this search should be dispatched in.
- */
- public String getRequestUiDispatchApp() {
- return getString("request.ui_dispatch_app", null);
- }
-
- /**
- * Returns the view this search should be displayed in.
- *
- * @return The view this search should be displayed in.
- */
- public String getRequestUiDispatchView() {
- return getString("request.ui_dispatch_view", null);
- }
-
- /**
- * Answers if a realtime search managed by the scheduler is restarted when
- * a search peer becomes available for this saved search.
- *
- * @return {@code true} if a realtime search is restarted when a new
- * search peer becomes available.
- */
- public boolean getRestartOnSearchPeerAdd() {
- return getBoolean("restart_on_searchpeer_add");
- }
-
- /**
- * Answers if this search is run when Splunk starts. If the search is not
- * run on startup, then it runs at the next scheduled time.
- *
- * @return {@code true} if this search is run when Splunk starts.
- */
- public boolean getRunOnStartup() {
- return getBoolean("run_on_startup");
- }
-
- /**
- * Returns the search expression for this saved search.
- *
- * @return The search expression.
- */
- public String getSearch() {
- return getString("search");
- }
-
- /**
- * Returns thew viewstate id associated with the view named in the
- * {@code displayView} property.
- *
- * @return The viewstate id.
- */
- public String getVsid() {
- return getString("vsid", null);
- }
-
- /**
- * Answers if the email action is enabled.
- *
- * @return {@code true} if the email action is enabled.
- */
- public boolean isActionEmail() {
- return getBoolean("action.email");
- }
-
- /**
- * Answers if the populate-lookup action is enabled.
- *
- * @return {@code true} if the populate-lookup action is enabled.
- */
- public boolean isActionPopulateLookup() {
- return getBoolean("action.populate_lookup");
- }
-
- /**
- * Answers if the RSS action is enabled.
- *
- * @return {@code true} if the RSS action is enabled.
- */
- public boolean isActionRss() {
- return getBoolean("action.rss");
- }
-
- /**
- * Answers if the script action is enabled.
- *
- * @return {@code true} if the script action is enabled.
- */
- public boolean isActioncScript() {
- return getBoolean("action.script");
- }
-
- /**
- * Answers if the summary-index action is enabled.
- *
- * @return {@code true} if the summary-index action is enabled.
- */
- public boolean isActionSummaryIndex() {
- return getBoolean("action.summary_index");
- }
-
- /**
- * Answers if Splunk applies the alert actions to the entire result set
- * or to each individual search result.
- *
- * @return Answer if Splunk applies the alert to the entire result set or
- * to each individual search result.
- */
- public boolean isDigestMode() {
- return getBoolean("alert.digest_mode");
- }
-
- /**
- * Answers if this search is run on a schedule.
- *
- * @return {@code true} if this search is run on a schedule.
- */
- public boolean isScheduled() {
- return getBoolean("is_scheduled");
- }
-
- /**
- * Answers if the search should be visible in the saved search list.
- *
- * @return {@code true} if the search should be visible in the saved search
- * list.
- */
- public boolean isVisible() {
- return getBoolean("is_visible");
- }
-
- /** {@inheritDoc} */
- @Override public void update(Map args) {
- // Updates to a saved search *require* that the search string be
- // passed, so add the current search string here if the value wasn't
- // passed in by the caller.
- if (!args.containsKey("search"))
- args = Args.create(args).add("search", getSearch());
- super.update(args);
- }
-}
diff --git a/splunk/com/splunk/ScriptInput.java b/splunk/com/splunk/ScriptInput.java
deleted file mode 100644
index 7db46b12..00000000
--- a/splunk/com/splunk/ScriptInput.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a script input.
- */
-public class ScriptInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The Script input endpoint.
- */
- ScriptInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this script input's group.
- *
- * @return This script input's group.
- */
- public String getGroup() {
- return getString("group", null);
- }
-
- /**
- * Returns this script input's source host, or null if not specified.
- *
- * @return This TCP input's source host.
- */
- public String getHost() {
- return getString("host", null);
- }
-
- /**
- * Returns this script input's index name.
- *
- * @return This script input's index name.
- */
- public String getIndex() {
- return getString("index");
- }
-
- /**
- * Returns this script input's execution frequency in seconds, or a cron
- * schedule.
- *
- * @return This scripts input's execution frequency in seconds, or a cron
- * schedule.
- */
- public String getInterval() {
- return getString("interval");
- }
-
- /**
- * Returns the script input kind.
- *
- * @return The script input kind.
- */
- public InputKind getKind() {
- return InputKind.Script;
- }
-
- /**
- * Returns this script input's _rcvbuf attribute.
- *
- * @return This script input's _rcvbuf attribute.
- */
- public int getRcvBuf() {
- return getInteger("_rcvbuf");
- }
-}
diff --git a/splunk/com/splunk/Service.java b/splunk/com/splunk/Service.java
deleted file mode 100644
index c826a466..00000000
--- a/splunk/com/splunk/Service.java
+++ /dev/null
@@ -1,657 +0,0 @@
-/*
- * Copyright 2011 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.InputStream;
-import java.util.Map;
-
-/**
- * Representation of a Splunk service at a given address (host:port) accessed
- * using a given protocol "scheme" ({@code http} or {@code https}). A service
- * instance also captures an optional namespace context consisting of
- * an optional owner name (or "-" wildcard) and optional app name (or "-"
- * wildcard. In order to access {@code Service} members the instance must
- * be authenticated by presenting credentials using the {@code login} method
- * or by constructing the instance using the {@code connect} method which
- * both creates and authenticates the instance.
- */
-public class Service extends HttpService {
- /** The current app context */
- protected String app = null;
-
- /** The current session token */
- protected String token = null;
-
- /** The current owner context */
- protected String owner = null;
-
- /** The username used to authenticate the instance */
- protected String username = null;
-
- /** The password used to authenticate the instance */
- protected String password = null;
-
- /** The default host name, used if no host is provided */
- public static String DEFAULT_HOST = "localhost";
-
- /** The default port number, used if no port is provided */
- public static int DEFAULT_PORT = 8089;
-
- /** The default scheme, used if no scheme is provided */
- public static String DEFAULT_SCHEME = "https";
-
- /**
- * Creates a new {@code Service} instance using the given host.
- *
- * @param host Host name of the service.
- */
- public Service(String host) {
- super(host);
- }
-
- /**
- * Creates a new {@code Service} instance using the given host and port.
- *
- * @param host Host name of the service.
- * @param port Port number of the service
- */
- public Service(String host, int port) {
- super(host, port);
- }
-
- /**
- * Creates a new {@code Service} instance using the given host, port and
- * scheme.
- *
- * @param host Host name of the service.
- * @param port Port number of the service.
- * @param scheme Scheme for accessing the service
- * ({@code http} or {@code https}).
- */
- public Service(String host, int port, String scheme) {
- super(host, port, scheme);
- }
-
- /**
- * Creates a new {@code Service} instance using the given
- * {@code ServiceArgs}
- *
- * @param args {@code ServiceArgs} to initialize the service.
- */
- public Service(ServiceArgs args) {
- super();
- this.app = args.app;
- this.host = args.host == null ? DEFAULT_HOST : args.host;
- this.owner = args.owner;
- this.port = args.port == null ? DEFAULT_PORT : args.port;
- this.scheme = args.scheme == null ? DEFAULT_SCHEME : args.scheme;
- this.token = args.token;
- }
-
- /**
- * Creates a new {@code Service} instance using the given {@code Map} of
- * service arguments.
- *
- * @param args {@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);
- }
-
- /**
- * Establish a connection to a Splunk service using the given arguments.
- * This member constructs a new {@code Service} instance and authenticates
- * the session using credentials passed in the {@code args} map.
- *
- * @param args Map of arguments used to initialize and authenticate the
- * sevice.
- * @return A new {@code Service} instance.
- */
- public static Service connect(Map args) {
- Service service = new Service(args);
- if (args.containsKey("username")) {
- String username = Args.get(args, "username", null);
- String password = Args.get(args, "password", null);
- service.login(username, password);
- }
- return service;
- }
-
- /**
- * Execute a search using the export endpoint which streams results back
- * in the returned {@code InputStream}.
- *
- * @param search The search query to execute.
- * @return {@code InputStream} containing the search results.
- */
- public InputStream export(String search) {
- return export(search, null);
- }
-
- /**
- * Execute a search using the export endpoint which streams results back
- * in the returned {@code InputStream}.
- *
- * @param search The search query to execute.
- * @param args Additional search arguments.
- * @return {@code InputStream} containing the search results.
- */
- public InputStream export(String search, Map args) {
- args = Args.create(args).add("search", search);
- ResponseMessage response = get("search/jobs/export", args);
- return response.getContent();
- }
-
- /**
- * Ensures that the given path is fully qualified, prepending a path
- * prefix if necessarry. The path prefix will be constructed using the
- * current owner & app context if available.
- *
- * @param path The path to verify.
- * @return A fully qualified resource path.
- */
- String fullpath(String path) {
- if (path.startsWith("/"))
- return path;
- if (owner == null && app == null)
- return "/services/" + path;
- return String.format("/servicesNS/%s/%s/%s",
- owner == null ? "-" : owner, app == null ? "-" : app, path);
- }
-
- /**
- * Returns the app context for this service instance, {@code null}
- * indicates no app context and {@code "-"} indicates an app wildcard.
- *
- * @return The app context for the service.
- */
- public String getApp() {
- return this.app;
- }
-
- /**
- * Returns the collection of applications.
- *
- * @return Application collection.
- */
- public EntityCollection getApplications() {
- return new EntityCollection(
- this, "apps/local", Application.class);
- }
-
- /**
- * Returns the collection of configurations.
- *
- * @return Configurations collection.
- */
- public ConfCollection getConfs() {
- return new ConfCollection(this);
- }
-
- /**
- * Returns an array of system capabilities.
- *
- * @return Capabilities.
- */
- public String[] getCapabilities() {
- Entity caps = new Entity(this, "authorization/capabilities");
- return caps.getStringArray("capabilities");
- }
-
- /**
- * Returns deployment client configuration and status.
- *
- * @return Deployment client configuration and status.
- */
- public DeploymentClient getDeploymentClient() {
- return new DeploymentClient(this);
- }
-
- /**
- * Returns the configuration of all deployment servers.
- *
- * @return Configuration of deployment servers.
- */
- public EntityCollection getDeploymentServers() {
- return new EntityCollection(
- this, "deployment/server", DeploymentServer.class);
- }
-
- /**
- * Returns collection of deployment server class configurations.
- *
- * @return Collection of server class configurations.
- */
- public EntityCollection getDeploymentServerClasses(){
- return new EntityCollection(
- this, "deployment/serverclass", DeploymentServerClass.class);
- }
-
- /**
- * Returns collection of multi-tenant configurations.
- *
- * @return Colleciton of multi-tenant configurations.
- */
- public EntityCollection getDeploymentTenants() {
- return new EntityCollection(
- this, "deployment/tenants", DeploymentTenant.class);
- }
-
- /**
- * Returns information regarding distributed search options.
- *
- * @return Distributed search information.
- */
- public DistributedConfiguration getDistributedConfiguration() {
- return new DistributedConfiguration(this);
- }
-
-
- /**
- * Returns collection of distributed search peers. A search peer is a
- * Splunk server to which another Splunk server distributes searches. The
- * Splunk server where the search originates is referred to as the search
- * head.
- *
- * @return Collection of search peers.
- */
- public EntityCollection getDistributedPeers() {
- return new EntityCollection(
- this, "search/distributed/peers", DistributedPeer.class);
- }
-
- /**
- * Returns collection of saved event types.
- *
- * @return Collection of saved event types.
- */
- public EventTypeCollection getEventTypes() {
- return new EventTypeCollection(this);
- }
-
- /**
- * Returns collection of alerts that have been fired by the service.
- *
- * @return Collection of fired alerts.
- */
- public EntityCollection getFiredAlerts() {
- return new EntityCollection(
- this, "alerts/fired_alerts", FiredAlert.class);
- }
-
- /**
- * Returns collection of Splunk indexes.
- *
- * @return Collection of indexes.
- */
- public EntityCollection getIndexes() {
- return new EntityCollection(this, "data/indexes", Index.class);
- }
-
- /**
- * Returns information about the Splunk service.
- *
- * @return Splunk service information.
- */
- public ServiceInfo getInfo() {
- return new ServiceInfo(this);
- }
-
- /**
- * Returns a collection of configured inputs.
- *
- * @return Collection of inputs.
- */
- public InputCollection getInputs() {
- return new InputCollection(this);
- }
-
- /**
- * Returns a collection of current search jobs.
- *
- * @return Collection of search jobs.
- */
- public JobCollection getJobs() {
- return new JobCollection(this);
- }
-
- /**
- * Returns collection of license group configurations.
- *
- * @return Collectio nof license group configurations.
- */
- public EntityCollection getLicenseGroups() {
- return new EntityCollection(
- this, "licenser/groups", LicenseGroup.class);
- }
-
- /**
- * Returns collection of messages from the licenser.
- *
- * @return Collection of licenser messages.
- */
- public EntityCollection getLicenseMessages() {
- return new EntityCollection(
- this, "licenser/messages", LicenseMessage.class);
- }
-
- /**
- * Returns the current owner context for this service instance,
- * {@code "-"} indicates wildcard and {@code null} indicates no owner
- * context.
- *
- * @return Current owner context.
- */
- public String getOwner() {
- return this.owner;
- }
-
- /**
- * Returns collection of licenser pool configurations.
- *
- * @return Collection of licenser pool configurations.
- */
- public LicensePoolCollection getLicensePools() {
- return new LicensePoolCollection(this);
- }
-
- /**
- * Returns collection of slaves reporting to this license master.
- *
- * @return Collection of licenser slaves.
- */
- public EntityCollection getLicenseSlaves() {
- return new EntityCollection(
- this, "licenser/slaves", LicenseSlave.class);
- }
-
- /**
- * Returns collection of license stack configurations.
- *
- * @return Collection of license stack configurations.
- */
- public EntityCollection getLicenseStacks() {
- return new EntityCollection(
- this, "licenser/stacks", LicenseStack.class);
- }
-
- /**
- * Returns collection of licenses for this service.
- *
- * @return Collection of licenses.
- */
- public EntityCollection getLicenses() {
- return new EntityCollection(
- this, "licenser/licenses", License.class);
- }
-
- /**
- * Returns collection of service logging categories and their status.
- *
- * @return Collection of logging categories.
- */
- public EntityCollection getLoggers() {
- return new EntityCollection(
- this, "server/logger", Logger.class);
- }
-
- /**
- * Returns collection of system messages.
- *
- * @return Collection of system messages.
- */
- public MessageCollection getMessages() {
- return new MessageCollection(this);
- }
-
- /**
- * Returns global TCP output properties.
- *
- * @return Global TCP output properties.
- */
- public OutputDefault getOutputDefault() {
- return new OutputDefault(this);
- }
-
- /**
- * Returns collection of output group configurations.
- *
- * @return Collection of output group configurations.
- */
- public EntityCollection getOutputGroups() {
- return new EntityCollection(
- this, "data/outputs/tcp/group", OutputGroup.class);
- }
-
- /**
- * Returns collection of data forwarding configurations.
- *
- * @return Collection of data forwarding configurations.
- */
- public EntityCollection getOutputServers() {
- return new EntityCollection(
- this, "data/outputs/tcp/server", OutputServer.class);
- }
-
- /**
- * Returns collection of configurations for forwarding data in standard
- * syslog format.
- *
- * @return Collection of syslog forwarders.
- */
- public EntityCollection getOutputSyslogs() {
- return new EntityCollection(
- this, "data/outputs/tcp/syslog", OutputSyslog.class);
- }
-
- /**
- * Returns the current password use to authenticate the session.
- *
- * @return Current password.
- */
- public String getPassword() {
- return this.password;
- }
-
- /**
- * Return collection of passwords, this collection is used for the
- * management of secure credentials.
- *
- * @return Collection of passwords.
- */
- public PasswordCollection getPasswords() {
- return new PasswordCollection(this);
- }
-
- /**
- * Returns a collection of Splunk user roles.
- *
- * @return Collection of user roles.
- */
- public EntityCollection getRoles() {
- return new EntityCollection(
- this, "authentication/roles", Role.class);
- }
-
- /**
- * Returns a collection of saved searches.
- *
- * @return Collection of saved searches.
- */
- public SavedSearchCollection getSavedSearches() {
- return new SavedSearchCollection(this);
- }
-
- /**
- * Returns service configuration information for an instance of Splunk.
- *
- * @return Service configuration information.
- */
- public Settings getSettings() {
- return new Settings(this);
- }
-
- /**
- * Returns the current session token. This allows sharing of session tokens
- * across multiple service instances.
- *
- * @return Session token.
- */
- public String getToken() {
- return this.token;
- }
-
- /**
- * Returns the username used to authenticate the current session.
- *
- * @return Current username.
- */
- public String getUsername() {
- return this.username;
- }
-
- /**
- * Returns collection of Splunk users.
- *
- * @return Collection of users.
- */
- public UserCollection getUsers() {
- return new UserCollection(this);
- }
-
- /**
- * Authenticate the instance using the given credentials.
- *
- * @param username User name.
- * @param password Password.
- * @return The current service instance.
- */
- public Service login(String username, String password) {
- this.username = username;
- this.password = password;
-
- Args args = new Args();
- args.put("username", username);
- args.put("password", password);
- ResponseMessage response = post("/services/auth/login", args);
- String sessionKey = Xml.parse(response.getContent())
- .getElementsByTagName("sessionKey")
- .item(0)
- .getTextContent();
- this.token = "Splunk " + sessionKey;
-
- return this;
- }
-
- /**
- * Forget the current session token.
- *
- * @return The current service instance.
- */
- public Service logout() {
- this.token = null;
- return this;
- }
-
- /**
- * Creates a 'oneshot' synchronous search.
- *
- * @param query The search query string.
- * @return The response message of the search.
- */
- public InputStream oneshot(String query) {
- return oneshot(query, null);
- }
-
- /**
- * Creates a 'oneshot' synchronous search.
- *
- * @param query The search query.
- * @param args The arguments to the search.
- * @return The results of the search.
- */
- public InputStream oneshot(String query, Map args) {
- args = Args.create(args);
- args.put("search", query);
- args.put("exec_mode", "oneshot");
- ResponseMessage response = post("search/jobs/", args);
- return response.getContent();
- }
-
- /**
- * Parse the given search query and return a semantic map for the search.
- *
- * @param query The query to parse.
- * @return Parse response message.
- */
- public ResponseMessage parse(String query) {
- return parse(query, null);
- }
-
- /**
- * Parse the given search query and return a semantic map for the search.
- *
- * @param query The query to parse.
- * @param args Additional parse arguments.
- * @return Parse response message.
- */
- public ResponseMessage parse(String query, Map args) {
- args = Args.create(args).add("q", query);
- return get("search/parser", args);
- }
-
- /**
- * Restart the service. The service will be unavailable until it has
- * sucessfully restarted.
- *
- * @return Restart response message.
- */
- public ResponseMessage restart() {
- return get("server/control/restart");
- }
-
- /**
- * Issue an HTTP request against the service using the given path and
- * request message. This method overrides the base HttpService send method
- * and applies the Splunk auth header which is required for authenticated
- * interactions with the Splunk service.
- *
- * @param path Request path.
- * @param request Request message.
- * @return HTTP response.
- */
- @Override public ResponseMessage send(String path, RequestMessage request) {
- request.getHeader().put("Authorization", token);
- return super.send(fullpath(path), request);
- }
-
- /**
- * Provides a session token for use by this service instance. This allows
- * sharing of session tokens across multiple service instances.
- *
- * @param value Session token.
- */
- public void setToken(String value) {
- this.token = value;
- }
-}
diff --git a/splunk/com/splunk/ServiceInfo.java b/splunk/com/splunk/ServiceInfo.java
deleted file mode 100644
index 0f2e928b..00000000
--- a/splunk/com/splunk/ServiceInfo.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Information regarding a service instance.
- */
-public class ServiceInfo extends Entity {
- ServiceInfo(Service service) {
- super(service, "server/info");
- }
-
- /**
- * Returns the service's build number.
- *
- * @return Build number.
- */
- public int getBuild() {
- return getInteger("build");
- }
-
- /**
- * Returns the service's CPU architecture.
- *
- * @return CPU architecture.
- */
- public String getCpuArch() {
- return getString("cpu_arch");
- }
-
- /**
- * Returns a GUID identifying the Splunk instance.
- *
- * @return GUID identifying the Splunk instance.
- */
- public String getGuid() {
- return getString("guid");
- }
-
- /**
- * Returns an array of the service's license keys.
- *
- * @return Array of license keys.
- */
- public String[] getLicenseKeys() {
- return getStringArray("licenseKeys", null);
- }
-
- /**
- * Returns the service's license signature.
- *
- * @return License signature.
- */
- public String getLicenseSignature() {
- return getString("licenseSignature");
- }
-
- /**
- * Returns the service's curernt license state.
- *
- * @return License state.
- */
- public String getLicenseState() {
- return getString("licenseState");
- }
-
- /**
- * Returns the GUID identifying the license master.
- *
- * @return GUID of the license master.
- */
- public String getMasterGuid() {
- return getString("master_guid");
- }
-
- /**
- * Returns the service's current mode.
- *
- * @return Service mode.
- */
- public String getMode() {
- return getString("mode");
- }
-
- /**
- * Returns the service's OS build.
- *
- * @return OS build.
- */
- public String getOsBuild() {
- return getString("os_build");
- }
-
- /**
- * Returns the service's OS version.
- *
- * @return OS version.
- */
- public String getOsVersion() {
- return getString("os_version");
- }
-
- /**
- * Returns the services server name.
- *
- * @return Server name.
- */
- public String getServerName() {
- return getString("serverName");
- }
-
- /**
- * Returns the services Splunk version number.
- *
- * @return Splunk version number.
- */
- public String getVersion() {
- return getString("version");
- }
-
- /**
- * Answers if the service is running under a free license.
- *
- * @return {@code true} if the current license is a free license.
- */
- public boolean isFree() {
- return getBoolean("isFree");
- }
-
- /**
- * Answers if the service is running under a trial license.
- *
- * @return {@code true} if the current license is a trial license.
- */
- public boolean isTrial() {
- return getBoolean("isTrial");
- }
-}
diff --git a/splunk/com/splunk/Settings.java b/splunk/com/splunk/Settings.java
deleted file mode 100644
index b379c03c..00000000
--- a/splunk/com/splunk/Settings.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of configuration information for an instance of Splunk.
- */
-public class Settings extends Entity {
- Settings(Service service) {
- super(service, "server/settings");
- }
-
- /**
- * Returns the fully qualified path to the directory containing the Splunk
- * index directories.
- *
- * @return Path to Splunk index directories.
- */
- public String getSplunkDB() {
- return getString("SPLUNK_DB");
- }
-
- /**
- * Returns the fully qualified path to the Splunk install directory.
- *
- * @return Path to Splunk install directory.
- */
- public String getSplunkHome() {
- return getString("SPLUNK_HOME");
- }
-
- /**
- * Answers if SSL is enabled on the Splunk maangement port.
- *
- * @return {@code true} if SSL is enabled.
- */
- public boolean getEnableSplunkWebSSL() {
- return getBoolean("enableSplunkWebSSL");
- }
-
- /**
- * Returns the service's host name.
- *
- * @return Service host name.
- */
- public String getHost() {
- return getString("host", null);
- }
-
- /**
- * Returns the splunkweb port number.
- *
- * @return Splunkweb port number.
- */
- public int getHttpPort() {
- return getInteger("httpport");
- }
-
- /**
- * Returns the splunkd port number.
- *
- * @return Splunkd port number.
- */
- public int getMgmtPort() {
- return getInteger("mgmtHostPort");
- }
-
- /**
- * Returns the value in megabytes of free disk space required for Splunk
- * to continue operating.
- *
- * @return Megabyes of free disk space required by Splunk.
- */
- public int getMinFreeSpace() {
- return getInteger("minFreeSpace");
- }
-
- /**
- * Returns the key that is prepended to the splunk symmetric key to
- * generate the final key used to sign all traffic between master & slave
- * licensers.
- *
- * @return Licenser symm key.
- */
- public String getPass4SymmKey() {
- return getString("pass4SymmKey");
- }
-
- /**
- * Returns the name used to identify this Splunk instance for features
- * such as distributed search.
- *
- * @return The name used to identify the Splunk instance.
- */
- public String getServerName() {
- return getString("serverName");
- }
-
- /**
- * Returns the amount of time before a user session times out.
- *
- * @return The amount of time before a user session times out.
- */
- public String getSessionTimeout() {
- return getString("sessionTimeout");
- }
-
- /**
- * Answers if the instance is configured to start splunkweb.
- *
- * @return {@code true} if the instance is configured to start splunkweb.
- */
- public boolean getStartWebServer() {
- return getBoolean("startwebserver");
- }
-
- /**
- * Returns the IP address of the authenticating proxy.
- *
- * @return IP address of authenticating proxy.
- */
- public String getTrustedIP() {
- return getString("trustedIP", null);
- }
-}
diff --git a/splunk/com/splunk/TcpInput.java b/splunk/com/splunk/TcpInput.java
deleted file mode 100644
index dd1b6110..00000000
--- a/splunk/com/splunk/TcpInput.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a TCP input. This differs from TCP cooked, as the data
- * indexed is not processed and in raw form.
- */
-public class TcpInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The TCP input endpoint.
- */
- TcpInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the style of host connection, or null if not specified. Valid
- * values are from the set ip, dns, and none.
- *
- * @return The style of host connection.
- */
- public String getConnectionHost() {
- return getString("connection_host", null);
- }
-
- /**
- * Returns this TCP input's group.
- *
- * @return This TCP input's group.
- */
- public String getGroup() {
- return getString("group");
- }
-
- /**
- * Returns this TPC input's source host, where this indexer gets its data.
- * Null is returned if it is not specified.
- *
- * @return This TCP input's source host.
- */
- public String getHost() {
- return getString("host", null);
- }
-
- /**
- * Returns this TCP input's index name, or null if not specified.
- *
- * @return This TCP input's index name.
- */
- public String getIndex() {
- return getString("index", null);
- }
-
- /**
- * Returns the TCP input kind.
- *
- * @return The TCP input kind.
- */
- public InputKind getKind() {
- return InputKind.Tcp;
- }
-
- /**
- * Returns this TCP input's queue, or null if not specified. Valid values
- * are from the set parsingQueue, indexQueue.
- *
- * @return This TCP input's queue.
- */
- public String getQueue() {
- return getString("queue", null);
- }
-
- /**
- * Returns this TCP input's _rcvbuf attribute.
- *
- * @return This TCP input's _rcvbuf attribute.
- */
- public int getRcvBuf() {
- return getInteger("_rcvbuf");
- }
-
- /**
- * Returns this TCP input's incoming host restriction, or null if not
- * specified.
- *
- * @return This TCP input's incoming host restriction.
- */
- public String getRestrictToHost() {
- return getString("restrictToHost", null);
- }
-
- /**
- * Returns this TCP input's initial source key, or null if not specified.
- * This is normally the input file path.
- *
- * @return This TCP input's source.
- */
- public String getSource() {
- return getString("source", null);
- }
-
- /**
- * Returns this TCP input's event source type, or null if not specified.
- *
- * @return this TCP input's event source type.
- */
- public String getSourceType() {
- return getString("sourceType", null);
- }
-
- /**
- * Returns Whether or not this TCP input is using SSL.
- *
- * @return Whether or not this TCP input is using SSL.
- */
- public boolean getSSL() {
- return getBoolean("SSL", false);
- }
-}
diff --git a/splunk/com/splunk/TcpSplunkInput.java b/splunk/com/splunk/TcpSplunkInput.java
deleted file mode 100644
index 5d742f8c..00000000
--- a/splunk/com/splunk/TcpSplunkInput.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a TCP cooked input. This differs from TCP, as the data
- * indexed is processed and not in raw form.
- */
-public class TcpSplunkInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The TCP cooked input endpoint.
- */
- TcpSplunkInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the style of host connection, or null if not specified. Valid
- * values are from the set ip, dns, and none.
- *
- * @return The style of host connection.
- */
- public String getConnectionHost() {
- return getString("connection_host", null);
- }
-
- /**
- * Returns this TCP cooked input's group.
- *
- * @return This TCP cooked input's group.
- */
- public String getGroup() {
- return getString("group");
- }
-
- /**
- * Returns this TCP cooked input's source host, where this indexer gets its
- * data. Null is returned if it is not specified.
- *
- * @return This TCP cooked input's source host.
- */
- public String getHost() {
- return getString("host");
- }
-
- /**
- * Returns this TCP cooked input's index name, or null if not specified.
- *
- * @return This TCP cooked input's index name.
- */
- public String getIndex() {
- return getString("index");
- }
-
- /**
- * Returns the TCP cooked input kind.
- *
- * @return The TCP cooked input kind.
- */
- public InputKind getKind() {
- return InputKind.TcpSplunk;
- }
-
- /**
- * Returns this TCP cooked input's queue, or null if not specified. Valid
- * values are from the set parsingQueue, indexQueue.
- *
- * @return This TCP cooked input's queue.
- */
- public String getQueue() {
- return getString("queue", null);
- }
-
- /**
- * Returns this TCP cooked input's _rcvbuf attribute.
- *
- * @return This TCP cooked input's _rcvbuf attribute.
- */
- public int getRcvBuf() {
- return getInteger("_rcvbuf");
- }
-
- /**
- * Returns this TCP cooked input's incoming host restriction, or null if not
- * specified.
- *
- * @return This TCP cooked input's incoming host restriction.
- */
- public String getRestrictToHost() {
- return getString("restrictToHost", null);
- }
-
- /**
- * Returns this TCP cooked input's initial source key, or null if not
- * specified. This is normally the input file path.
- *
- * @return This TCP cooked input's source.
- */
- public String getSource() {
- return getString("source", null);
- }
-
- /**
- * Returns this TCP cooked input's event source type, or null if not
- * specified.
- *
- * @return this TCP cooked input's event source type.
- */
- public String getSourceType() {
- return getString("sourceType", null);
- }
-
- /**
- * Returns Whether or not this TCP cooked input is using SSL.
- *
- * @return Whether or not this TCP cooked input is using SSL.
- */
- public boolean getSSL() {
- return getBoolean("SSL", false);
- }
-}
diff --git a/splunk/com/splunk/UdpInput.java b/splunk/com/splunk/UdpInput.java
deleted file mode 100644
index 67a8269b..00000000
--- a/splunk/com/splunk/UdpInput.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a UDP input.
- */
-public class UdpInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The UDP input endpoint.
- */
- UdpInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the style of host connection, or null if not specified. Valid
- * values are from the set ip, dns, and none.
- *
- * @return The style of host connection.
- */
- public String getConnectionHost() {
- return getString("connection_host", null);
- }
-
- /**
- * Returns this UDP input's group.
- *
- * @return This UDP input's group.
- */
- public String getGroup() {
- return getString("group");
- }
-
- /**
- * Returns this UDP input's source host, where this indexer gets its data.
- * Null is returned if it is not specified.
- *
- * @return This UDP input's source host.
- */
- public String getHost() {
- return getString("host");
- }
-
- /**
- * Returns this UDP input's index name, or null if not specified.
- *
- * @return This UDP input's index name.
- */
- public String getIndex() {
- return getString("index");
- }
-
- /**
- * Returns the UDP input kind.
- *
- * @return The UDP input kind.
- */
- public InputKind getKind() {
- return InputKind.Udp;
- }
-
- /**
- * Returns this UDP input's queue, or null if not specified. Valid values
- * are from the set parsingQueue, indexQueue.
- *
- * @return This UDP input's queue.
- */
- public String getQueue() {
- return getString("queue", null);
- }
-
- /**
- * Returns this UDP input's _rcvbuf attribute.
- *
- * @return This UDP input's _rcvbuf attribute.
- */
- public int getRcvBuf() {
- return getInteger("_rcvbuf");
- }
-
- /**
- * Returns this UDP input's initial source key, or null if not specified.
- * This is normally the input file path.
- *
- * @return This UDP input's source.
- */
- public String getSource() {
- return getString("source", null);
- }
-
- /**
- * Returns this UDP input's event source type, or null if not specified.
- *
- * @return this UDP input's event source type.
- */
- public String getSourceType() {
- return getString("sourceType", null);
- }
-
- /**
- * Returns whether or not Splunk prepends a timestamp and hostname to
- * incoming events.
- *
- * @return Whether or not Splunk prepends a timestamp and hostname to
- * incoming events.
- */
- public boolean noAppendingTimeStamp() {
- return getBoolean("no_appending_timestamp", false);
- }
-
- /**
- * Returns whether or not Splunk removes the priority field to incoming
- * events.
- *
- * @return Whether or not Splunk removes the priority field to incoming
- * events.
- */
- public boolean noPriorityStripping() {
- return getBoolean("no_priority_stripping", false);
- }
-}
diff --git a/splunk/com/splunk/User.java b/splunk/com/splunk/User.java
deleted file mode 100644
index 4268b819..00000000
--- a/splunk/com/splunk/User.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Splunk user.
- */
-public class User extends Entity {
-
- /**
- * Constructs an instance of the User entity.
- *
- * @param service The service the entity is affiliated with.
- * @param path The resource path.
- */
- User(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns the user's default app.
- *
- * @return The user's default app.
- */
- public String getDefaultApp() {
- return getString("defaultApp", null);
- }
-
- /**
- * Answers if the user's default app was set specifically by the user.
- *
- * @return {@code true} if the default app was set by the user.
- */
- public boolean getDefaultAppIsUserOverride() {
- return getBoolean("defaultAppIsUserOverride");
- }
-
- /**
- * If the default app was inherited from a role, this returns the name of
- * the role it was inherited from, or {@code system} if it was inherited
- * from the default system setting.
- *
- * @return The name of the role the default app was inherited from, or
- * {@code system} if it was inherited from the default system
- * settings.
- */
- public String getDefaultAppSourceRole() {
- return getString("defaultAppSourceRole");
- }
-
- /**
- * Returns the user's email address.
- *
- * @return The user's email address.
- */
- public String getEmail() {
- return getString("email", null);
- }
-
- /**
- * Returns the user's password.
- *
- * @return The user's password.
- */
- public String getPassword() {
- return getString("password", null);
- }
-
- /**
- * Returns the full name associated with this user.
- *
- * @return The full name associated with this user.
- */
- public String getRealName() {
- return getString("realname", null);
- }
-
- /**
- * Returns an array of roles assigned to this user.
- *
- * @return Array of roles assigned to this user.
- */
- public String[] getRoles() {
- return getStringArray("roles", null);
- }
-
- /**
- * Returns the authentication method responsible for this user.
- *
- * @return The authentication method repsonsible for this user.
- */
- public String getType() {
- return getString("type", null);
- }
-
- /**
- * Returns the timezone to use when displaying dates for this user.
- *
- * @return The timezone to use when displaying dates for this user.
- */
- public String getTz() {
- return getString("tz", null);
- }
-}
diff --git a/splunk/com/splunk/UserCollection.java b/splunk/com/splunk/UserCollection.java
deleted file mode 100644
index 32afa1dc..00000000
--- a/splunk/com/splunk/UserCollection.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2011 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.Map;
-
-/**
- * Representation of a collection of user entities.
- */
-public class UserCollection extends EntityCollection {
-
- /**
- * Constructs an instance of {@code UserCollection}.
- *
- * @param service This service instance this collection is affiliated with.
- */
- UserCollection(Service service) {
- super(service, "authentication/users", User.class);
- }
-
- /**
- * Create a new user entity using the given name, password and role.
- *
- * @param name The name for the new user entity.
- * @param password The password for the new user entity.
- * @param role The role to assign to the new entity.
- * @return The newly craeted user entity.
- */
- public User create(String name, String password, String role) {
- return create(name, password, role, null);
- }
-
- /**
- * Create a new user entity using the given name, password and array of
- * roles.
- *
- * @param name The name for the new user entity.
- * @param password The password for the new user entity.
- * @param roles Array of roles to assign to the new user entity.
- * @return The newly created user entity.
- */
- public User create(String name, String password, String[] roles) {
- return create(name, password, roles, null);
- }
-
- /**
- * Create a new user entity using the given name, password, role and
- * map of extra args.
- *
- * @param name The name for the new user entity.
- * @param password The password for the new user entity.
- * @param role The role to assign to the new entity.
- * @param args A map of extra arguments for the new user entity.
- * @return The newly created user entity.
- */
- public User create(String name, String password, String role, Map args) {
- args = Args.create(args);
- args.put("password", password);
- args.put("roles", role);
- return create(name, args);
- }
-
-
- /**
- * Create a new user entity using the given name, password and array of
- * roles.
- *
- * @param name The name for the new user entity.
- * @param password The password for the new user entity.
- * @param roles Array of roles to assign to the new user entity.
- * @param args A map of extra arguments for the new user entity.
- * @return The newly created user entity.
- */
- public User
- create(String name, String password, String[] roles, Map args) {
- args = Args.create(args);
- args.put("password", password);
- args.put("roles", roles);
- return create(name, args);
- }
-}
diff --git a/splunk/com/splunk/WindowsActiveDirectoryInput.java b/splunk/com/splunk/WindowsActiveDirectoryInput.java
deleted file mode 100644
index 10de91c7..00000000
--- a/splunk/com/splunk/WindowsActiveDirectoryInput.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Windows Active Directory input.
- */
-public class WindowsActiveDirectoryInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The Windows Active Directory input endpoint.
- */
- WindowsActiveDirectoryInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this Windows Active Directory input's index name, or null if not
- * specified.
- *
- * @return This Windows Active Directory input's index name.
- */
- public String getIndex() {
- return getString("index", null);
- }
-
- /**
- * Returns the Windows Active Directory input kind.
- *
- * @return The Windows Active Directory input kind.
- */
- public InputKind getKind() {
- return InputKind.WindowsActiveDirectory;
- }
-
- /**
- * Returns whether or not this Windows Active Directory input's directory
- * path subtree is being monitored.
- *
- * @return Whether or not this Windows Active Directory input's directory
- * path subtree is being monitored.
- */
- public boolean getMonitorSubtree() {
- return getBoolean("monitorSubtree");
- }
-
- /**
- * Returns this Windows Active Directory input's starting location in the
- * directory path. Null if not specified. If not specified, the the root of
- * the directory tree is used.
- *
- * @return this Windows Active Directory input's starting location in the
- * directory path.
- */
- public String getStartingNode() {
- return getString("startingNode", null);
- }
-
- /**
- * Returns the fully qualified domain name of a valid, network accessible
- * Domain Controller. Null if not specified. If not specified, the local
- * machine is used.
- *
- * @return The fully qualified domain name.
- */
- public String getTargetDc() {
- return getString("targetDc", null);
- }
-}
diff --git a/splunk/com/splunk/WindowsEventLogInput.java b/splunk/com/splunk/WindowsEventLogInput.java
deleted file mode 100644
index e1fd2a2c..00000000
--- a/splunk/com/splunk/WindowsEventLogInput.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Windows Event Log input.
- */
-public class WindowsEventLogInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The Windows Event Log input endpoint.
- */
- WindowsEventLogInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns a comma separated list of additional hosts used in monitoring.
- *
- * @return additional hosts used in monitoring.
- */
- public String getHosts() {
- return getString("hosts", null);
- }
-
- /**
- * Returns this Windows Event Log input's index name, or null if not
- * specified.
- *
- * @return This Windows Event Log input's index name.
- */
- public String getIndex() {
- return getString("index", null);
- }
-
- /**
- * Returns the Windows Event Log input kind.
- *
- * @return The Windows Event Log input kind.
- */
- public InputKind getKind() {
- return InputKind.WindowsEventLog;
- }
-
- /**
- * Returns this Windows Event log input's list of event log names.
- *
- * @return This Windows Event log input's list of event log names.
- */
- public String [] getLogs() {
- return getStringArray("logs", null);
- }
-
- /**
- * Returns this Windows Event log input's collection name. This name
- * appears in configuration file, as well as the source and the sourcetype of
- * the indexed data. If the value is "localhost", it will use native event
- * log collection; otherwise, it will use WMI.
- *
- * @return This Windows Event log input's collection.
- */
- public String getLocalName() {
- return getString("name");
- }
-
- /**
- * Returns this Windows Event log input's main host. Secondary hosts are
- * specified in the hosts attribute.
- *
- * @return This Windows Event log input's main host.
- */
- public String getLookupHost() {
- return getString("lookup_host");
- }
-}
diff --git a/splunk/com/splunk/WindowsPerfmonInput.java b/splunk/com/splunk/WindowsPerfmonInput.java
deleted file mode 100644
index 5d9f3220..00000000
--- a/splunk/com/splunk/WindowsPerfmonInput.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Windows Perfmon input.
- */
-public class WindowsPerfmonInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The Windows Perfmon input endpoint.
- */
- WindowsPerfmonInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this Windows Perfmon input's monitored counters. This is a comma
- * separated list. Null is returned if not specified.
- *
- * @return This Windows Perfmon input's counters.
- */
- public String getCounters() {
- return getString("counters", null);
- }
-
- /**
- * Returns this Windows Perfmon input's index name, or null if not
- * specified.
- *
- * @return This Windows Perfmon input's index name.
- */
- public String getIndex() {
- return getString("index", null);
- }
-
- /**
- * Returns this Windows Perfmon input's counter instances. A wildcard
- * equivocates to all instances.
- *
- * @return This Windows Perfmon input's counter instances.
- */
- public String getInstances() {
- return getString("instances", null);
- }
-
- /**
- * Returns the frequency, in seconds, to poll this Windows Perfmon input's
- * performance counters.
- *
- * @return This Windows Perfmon polling frequency.
- */
- public int getInterval() {
- return getInteger("interval");
- }
-
- /**
- * Returns the Windows Perfmon input kind.
- *
- * @return The Windows Perfmon input kind.
- */
- public InputKind getKind() {
- return InputKind.WindowsPerfmon;
- }
-
- /**
- * Returns this Windows Perfmon input's Windows performance object.
- *
- * @return This Windows Perfmon input's Windows performance object.
- */
- public String getObject() {
- return getString("object");
- }
-}
diff --git a/splunk/com/splunk/WindowsRegistryInput.java b/splunk/com/splunk/WindowsRegistryInput.java
deleted file mode 100644
index b3646c33..00000000
--- a/splunk/com/splunk/WindowsRegistryInput.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Windows Registry input.
- */
-public class WindowsRegistryInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The Windows Registry input endpoint.
- */
- WindowsRegistryInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns whether or not this Windows Registry input has a baseline
- * established.
- *
- * @return Whether or not this Windows Registry input has a baseline
- * established.
- */
- public boolean getBaseline() {
- return getBoolean("baseline");
- }
-
- /**
- * Returns this Windows Registry input's regular expression (regex) that is
- * executed against process names when including/excluding events.
- *
- * @return This Windows Registry input's process regular expression.
- */
- public String getProc() {
- return getString("proc");
- }
-
- /**
- * Returns this Windows Registry input's hive name to monitor.
- *
- * @return This Windows Registry input's hive name to monitor.
- */
- public String getHive() {
- return getString("hive");
- }
-
- /**
- * Returns this Windows Registry input's index name, or null if not
- * specified.
- *
- * @return This Windows Registry input's index name.
- */
- public String getIndex() {
- return getString("index");
- }
-
- /**
- * Returns the Windows Registry input kind.
- *
- * @return The Windows Registry input kind.
- */
- public InputKind getKind() {
- return InputKind.WindowsRegistry;
- }
-
- /**
- * Returns whether or not this Windows Registry input monitors all
- * sub-nodes under a given hive.
- *
- * @return Whether or not this Windows Registry input monitors all
- * sub-nodes under a given hive.
- */
- public boolean getMonitorSubnodes() {
- return getBoolean("monitorSubnodes", false);
- }
-
- /**
- * Returns this Windows Registry input's regular expression (regex) that is
- * executed against registry event types.
- *
- * @return This Windows Registry input's registry type regular expression.
- */
- public String getType() {
- return getString("type", null);
- }
-}
diff --git a/splunk/com/splunk/WindowsWmiInput.java b/splunk/com/splunk/WindowsWmiInput.java
deleted file mode 100644
index 38592180..00000000
--- a/splunk/com/splunk/WindowsWmiInput.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2011 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;
-
-/**
- * Representation of a Windows WMI input.
- */
-public class WindowsWmiInput extends Input {
-
- /**
- * Class Constructor.
- *
- * @param service The connected service instance.
- * @param path The Windows WMI input endpoint.
- */
- WindowsWmiInput(Service service, String path) {
- super(service, path);
- }
-
- /**
- * Returns this Windows WMI input's WMI class name.
- *
- * @return This Windows WMI input's WMI class name.
- */
- public String getClasses() {
- return getString("classes");
- }
-
- /**
- * Returns this Windows WMI input's properties list collected for
- * this class.
- *
- * @return This Windows WMI input's properties list collected for
- * this class.
- */
- public String [] getFields() {
- return getStringArray("fields", null);
- }
-
- /**
- * Returns this Windows WMI input's index name, or null if not specified.
- *
- * @return This Windows WMI input's index name.
- */
- public String getIndex() {
- return getString("index", null);
- }
-
- /**
- * Returns a list of this Windows WMI class instances.
- *
- * @return A list of this Windows WMI class instances.
- */
- public String [] getInstances() {
- return getStringArray("instances", null);
- }
-
- /**
- * Returns the frequency, in seconds, to query this Windows WMI input
- * providers.
- *
- * @return This Windows WMI query frequency.
- */
- public int getInterval() {
- return getInteger("interval");
- }
-
- /**
- * Returns the Windows WMI input kind.
- *
- * @return The Windows WMI input kind.
- */
- public InputKind getKind() {
- return InputKind.WindowsWmi;
- }
-
- /**
- * Returns this Windows WMI input's main host. Secondary hosts are
- * specified in the server attribute.
- *
- * @return This Windows WMI input's main host.
- */
- public String getLookupHost() {
- return getString("lookup_host");
- }
-
- /**
- * Returns this Windows WMI input's collection name. This name appears in
- * configuration file, as well as the source and the sourcetype of the
- * indexed data.
- *
- * @return This Windows WMI input's collection.
- */
- public String getLocalName() {
- return getString("name");
- }
-
- /**
- * Returns a comma separated list of additional servers used in monitoring.
- *
- * @return additional servers used in monitoring.
- */
- public String getServer() {
- return getString("server", null);
- }
-
- /**
- * Returns this Windows WMI input's query string.
- *
- * @return This Windows WMI input's query string.
- */
- public String getWql() {
- return getString("wql");
- }
-}
diff --git a/splunk/com/splunk/Xml.java b/splunk/com/splunk/Xml.java
deleted file mode 100644
index c32888d2..00000000
--- a/splunk/com/splunk/Xml.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2011 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.InputStream;
-import java.io.InputStreamReader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
-/**
- * A collection of XML utilities.
- */
-public class Xml {
-
- /**
- * Parse the given {@code InputStream} and return as an XML DOM.
- *
- * @param input Input stream.
- * @return XML DOM.
- */
- public static Document parse(InputStream input) {
- try {
- DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- // We are glossing namespaces for now as we can currently
- // disambiguate everything in the Splunk REST API via local name.
- factory.setNamespaceAware(false);
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputSource inputSource = new InputSource();
- inputSource.setCharacterStream(new InputStreamReader(input));
- return builder.parse(inputSource);
- }
- catch (Exception e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-}
-
diff --git a/splunk/pom.xml b/splunk/pom.xml
new file mode 100644
index 00000000..7dede37e
--- /dev/null
+++ b/splunk/pom.xml
@@ -0,0 +1,97 @@
+
+
+ 4.0.0
+
+ splunk
+ 1.9.5
+
+ splunk-sdk-java
+ com.splunk
+ 1.0.1
+
+
+ TLSv1.2
+
+
+
+ junit
+ junit
+ 4.13.1
+ test
+
+
+ commons-cli
+ commons-cli
+ 1.2
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.2.0
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.3.0
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M5
+
+ ${skipTests}
+ alphabetical
+
+ ${https.protocols}
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.8
+
+
+
+ prepare-agent
+
+
+
+
+ report
+ test
+
+ report
+
+
+ target/test-report
+
+
+
+
+
+
+
+
diff --git a/splunk/splunk.iml b/splunk/splunk.iml
index b6f444bc..2fbe4c0c 100644
--- a/splunk/splunk.iml
+++ b/splunk/splunk.iml
@@ -7,6 +7,9 @@
+
+
+
diff --git a/splunk/src/main/java/com/splunk/Application.java b/splunk/src/main/java/com/splunk/Application.java
new file mode 100644
index 00000000..6e44068a
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/Application.java
@@ -0,0 +1,221 @@
+/*
+ * 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;
+
+/**
+ * The {@code Application} class represents a locally-installed Splunk app.
+ */
+public class Application extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The application endpoint.
+ */
+ Application(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the name of the app's author. For Splunkbase
+ * apps, this value is the username of the Splunk.com account. For internal
+ * apps, this value is the full name.
+ *
+ * @return The author name, or {@code null} if not specified.
+ */
+ public String getAuthor() {
+ return getString("author", null);
+ }
+
+ /**
+ * Indicates whether Splunk checks Splunkbase for updates.
+ *
+ * @return {@code true} if Splunk checks Splunkbase for app updates,
+ * {@code false} if not.
+ */
+ public boolean getCheckForUpdates() {
+ return getBoolean("check_for_updates", false);
+ }
+
+ /**
+ * Returns a short description of the app.
+ *
+ * @return The description, or {@code null} if not specified.
+ */
+ public String getDescription() {
+ return getString("description", null);
+ }
+
+ /**
+ * Returns the app's label (its name).
+ *
+ * @return The label, or {@code null} if not specified.
+ */
+ public String getLabel() {
+ return getString("label", null);
+ }
+
+ /**
+ * Indicates whether to reload objects contained in the locally-installed
+ * app.
+ *
+ * @return {@code true} if objects are reloaded, {@code false} if not.
+ */
+ public boolean getRefresh() {
+ return getBoolean("refresh", false);
+ }
+
+ /**
+ * Returns the version of the app.
+ *
+ * @return The version, or {@code null} if not specified.
+ */
+ public String getVersion() {
+ return getString("version", null);
+ }
+
+ /**
+ * Indicates whether the app's custom setup has been
+ * performed. This field is available in Splunk version 4.2.4 and later.
+ *
+ * @return {@code true} if custom setup has been performed, {@code false}
+ * if not.
+ */
+ public boolean isConfigured() {
+ return getBoolean("configured", false);
+ }
+
+ /**
+ * Indicates whether the app is visible and navigable from Splunk Web.
+ *
+ * @return {@code true} if the app is visible and navigable from Splunk
+ * Web, {@code false} if not.
+ */
+ public boolean isVisible() {
+ return getBoolean("visible", false);
+ }
+
+ /**
+ * Indicates whether a state change requires the app to be restarted.
+ *
+ * @return {@code true} if state changes require the app to be restarted,
+ * {@code false} if not.
+ */
+ public boolean stateChangeRequiresRestart() {
+ return getBoolean("state_change_requires_restart", false);
+ }
+
+ /***
+ * Sets the name of the app's author. For Splunkbase apps, this value is
+ * the username of the Splunk.com account. For internal apps, this value is
+ * the full name.
+ *
+ * @param author The author name.
+ */
+ public void setAuthor(String author) {
+ setCacheValue("author", author);
+ }
+
+ /**
+ * Sets whether Splunk checks Splunkbase for updates to the app.
+ *
+ * @param value {@code true} if Splunk checks Splunkbase for app updates,
+ * {@code false} if not.
+ */
+ public void setCheckForUpdates(boolean value) {
+ setCacheValue("check_for_updates", value);
+ }
+
+ /**
+ * Sets whether the app's custom setup has been performed. This field
+ * is available in Splunk 4.2.4 and later.
+ *
+ * @param value {@code true} if the app has run its custom setup,
+ * {@code false} if not.
+ */
+ public void setConfigured(boolean value) {
+ setCacheValue("configured", value);
+ }
+
+ /**
+ * Sets a short description of the application, which is displayed below
+ * the app's title on the Splunk Home tab in Splunk Web.
+ *
+ * @param description The short description of the app.
+ */
+ public void setDescription(String description) {
+ setCacheValue("description", description);
+ }
+
+ /**
+ * Sets the app's name, which is displayed in Splunk Web. The name should be
+ * between 5-80 characters and should not include the prefix "Splunk For".
+ *
+ * @param label The label (name) of the app.
+ */
+ public void setLabel(String label) {
+ setCacheValue("label", label);
+ }
+
+ /**
+ * Sets the version of the app.
+ *
+ * @param version The app's version.
+ */
+ public void setVersion(String version) {
+ setCacheValue("version", version);
+ }
+
+ /**
+ * Sets whether the app is visible and navigable from Splunk Web.
+ *
+ * @param visible {@code true} if the app can be visible and navigable
+ * from Splunk Web, {@code false} if not.
+ */
+ public void setVisible(boolean visible) {
+ setCacheValue("visible", visible);
+ }
+
+ /**
+ * Archives the app on the server file system.
+ *
+ * @return The location of the archived app, as {app_name}.spl.
+ */
+ public ApplicationArchive archive() {
+ return new ApplicationArchive(service, path);
+ }
+
+ /**
+ * Returns the app's setup information.
+ *
+ * @return The app's setup information.
+ */
+ public ApplicationSetup setup() {
+ return new ApplicationSetup(service, path);
+ }
+
+ /**
+ * Returns any update information that is available for the app.
+ *
+ * @return Update information for the app.
+ */
+ public ApplicationUpdate getUpdate() {
+ return new ApplicationUpdate(service, path);
+ }
+}
+
diff --git a/splunk/com/splunk/ApplicationArchive.java b/splunk/src/main/java/com/splunk/ApplicationArchive.java
similarity index 54%
rename from splunk/com/splunk/ApplicationArchive.java
rename to splunk/src/main/java/com/splunk/ApplicationArchive.java
index 7392cf44..1ce41d98 100644
--- a/splunk/com/splunk/ApplicationArchive.java
+++ b/splunk/src/main/java/com/splunk/ApplicationArchive.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,44 +17,54 @@
package com.splunk;
/**
- * Representation of a Splunk application archive.
+ * The {@code ApplicationArchive} class represents an archive of a Splunk app.
*/
public class ApplicationArchive extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
- * @param path the full-path of the parent endpoint.
+ * @param service The connected {@code Service} instance.
+ * @param path The application endpoint.
*/
ApplicationArchive(Service service, String path) {
super(service, path + "/package");
}
/**
- * Returns the app name.
+ * Returns the name of the app.
*
- * @return The app name string.
+ * @return The app's name.
*/
public String getAppName() {
return getString("name");
}
/**
- * Returns the file path, on the server where the archive file is stored,
- * accessible with direct file access on the server.
+ * Returns a path indicating where the app archive file is stored on the
+ * server, for direct file access.
*
- * @return The server file path of the archive file.
+ * @return The path to the archive file.
*/
public String getFilePath() {
return getString("path");
}
/**
- * Returns the URL that points to the archive file on the server, accessible
- * with a browser.
+ * Indicates whether to reload the objects contained in the
+ * locally-installed app.
*
- * @return The URL of the archive file.
+ * @return {@code true} if objects are reloaded, {@code false} if not.
+ */
+ public boolean getRefresh() {
+ return getBoolean("refresh", false);
+ }
+
+ /**
+ * Returns a URL to the app archive file on the server, for web browser
+ * access.
+ *
+ * @return The URL to the archive file.
*/
public String getUrl() {
return getString("url");
diff --git a/splunk/com/splunk/ApplicationSetup.java b/splunk/src/main/java/com/splunk/ApplicationSetup.java
similarity index 61%
rename from splunk/com/splunk/ApplicationSetup.java
rename to splunk/src/main/java/com/splunk/ApplicationSetup.java
index 0139c4c1..1caca007 100644
--- a/splunk/com/splunk/ApplicationSetup.java
+++ b/splunk/src/main/java/com/splunk/ApplicationSetup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,30 +17,41 @@
package com.splunk;
/**
- * Representation of Splunk application setup information.
+ * The {@code ApplicationSetup} class represents the setup information for a
+ * Splunk app.
*/
public class ApplicationSetup extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
- * @param path the full-path of the parent endpoint.
+ * @param service The connected {@code Service} instance.
+ * @param path The application endpoint.
*/
ApplicationSetup(Service service, String path) {
super(service, path + "/setup");
}
+ /**
+ * Indicates whether to reload the objects contained in the
+ * locally-installed app.
+ *
+ * @return {@code true} if objects are reloaded, {@code false} if not.
+ */
+ public boolean getRefresh() {
+ return getBoolean("refresh", false);
+ }
+
/**
* Returns the app's setup information in XML format.
*
- * @return The app's setup information in XML format.
+ * @return The setup information for the app.
*/
public String getSetupXml() {
return getString("eai:setup");
}
// Because all other keys are dynamic and context specific, they should
- // be retrieved via standard Map access.
+ // be retrieved using Map (dictionary) get access.
}
diff --git a/splunk/com/splunk/ApplicationUpdate.java b/splunk/src/main/java/com/splunk/ApplicationUpdate.java
similarity index 58%
rename from splunk/com/splunk/ApplicationUpdate.java
rename to splunk/src/main/java/com/splunk/ApplicationUpdate.java
index b780904c..66adaced 100644
--- a/splunk/com/splunk/ApplicationUpdate.java
+++ b/splunk/src/main/java/com/splunk/ApplicationUpdate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,87 +17,88 @@
package com.splunk;
/**
- * Representation of a Splunk application update information.
+ * The {@code ApplicationUpdate} class represents information for an update
+ * to a locally-installed Splunk app.
*/
public class ApplicationUpdate extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
- * @param path the full-path of the parent endpoint.
+ * @param service The connected {@code Service} instance.
+ * @param path The application endpoint.
*/
ApplicationUpdate(Service service, String path) {
super(service, path + "/update");
}
/**
- * Returns the app's fully qualified update URL, or null if not specified.
+ * Returns the fully-qualified URL to the app update.
*
- * @return the app's update URL.
+ * @return The URL of the app update, or {@code null} if not specified.
*/
public String getAppUrl() {
return getString("update.appurl", null);
}
/**
- * Returns the checksum of the app, or null if not specified.
+ * Returns the checksum of the app.
*
- * @return The checksum of them app.
+ * @return The checksum of the app, or {@code null} if not specified.
*/
public String getChecksum() {
return getString("update.checksum", null);
}
/**
- * Returns the checksum type of the app, or null if not specified.
+ * Returns the checksum type of the app.
*
- * @return the checksum type of the app.
+ * @return The checksum type, or {@code null} if not specified.
*/
public String getChecksumType() {
return getString("update.checksum.type", null);
}
/**
- * Returns the app's fully qualified homepage URL, or null if not specified.
+ * Returns the fully-qualified URL to the app's homepage.
*
- * @return The app's homepage URL.
+ * @return The URL of the app's homepage, or {@code null} if not specified.
*/
public String getHomepage() {
return getString("update.homepage", null);
}
/**
- * Returns the app's name, or null if not specified.
+ * Returns the app's name.
*
- * @return The app's name.
+ * @return The app's name, or {@code null} if not specified.
*/
public String getUpdateName() {
return getString("update.name", null);
}
/**
- * Returns the app's update size, in bytes, or -1 if not specified.
+ * Returns the size of the app update.
*
- * @return The app's update size.
+ * @return The size of the update, in bytes, or -1 if not specified.
*/
public int getSize() {
return getInteger("update.size", -1);
}
/**
- * Returns the app's version string, or null if not specified.
+ * Returns the app's version.
*
- * @return The app's version.
+ * @return The app's version, or {@code null} if not specified.
*/
public String getVersion() {
return getString("update.version", null);
}
/**
- * Returns whether or not implicit ID is required.
+ * Indicates whether an implicit ID is required.
*
- * @return A boolean indicating if implicit ID is required.
+ * @return {@code true} if an implicit ID is required, {@code false} if not.
*/
public boolean isImplicitIdRequired() {
return getBoolean("update.implicit_id_required", false);
diff --git a/splunk/com/splunk/Args.java b/splunk/src/main/java/com/splunk/Args.java
similarity index 68%
rename from splunk/com/splunk/Args.java
rename to splunk/src/main/java/com/splunk/Args.java
index efd3bbf0..4e93f36a 100644
--- a/splunk/com/splunk/Args.java
+++ b/splunk/src/main/java/com/splunk/Args.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -18,18 +18,19 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
- * A helper for Splunk REST API arguments.
+ * The {@code Args} class is a helper class for working with Splunk REST API
+ * arguments.
*
- * The extension is mainly for encoding arguments for UTF8 transmission
- * to the Splunk instance in a key?value pairing for a string object, or
- * key?value1&key?value2, etc for an array of strings object.
+ * This extension is used mainly for encoding arguments for UTF8 transmission
+ * to a Splunk instance in a key=value pairing for a string, or
+ * {@code key=value1&key=value2 } (and so on) for an array of strings.
*/
-public class Args extends HashMap {
+public class Args extends LinkedHashMap {
/**
* Class constructor.
@@ -37,10 +38,11 @@ public class Args extends HashMap {
public Args() { super(); }
/**
- * Class constructor. Initialization of a single key/value pair.
+ * Class constructor. Initializes a single key-value pair.
*
* @param key The key name.
- * @param value The value (String or String [])
+ * @param value The value, as a {@code String:String} or
+ * {@code String:String[]}.
*/
public Args(String key, Object value) {
super();
@@ -48,20 +50,21 @@ public Args(String key, Object value) {
}
/**
- * Class constructor. Initialization of a pre-existing hash map.
+ * Class constructor. Initializes a pre-existing hash map.
*
- * @param values A set of key/value pairings.
+ * @param values A set of key-value pairs.
*/
public Args(Map values) {
super(values);
}
/**
- * Adds to an args set.
+ * Adds an argument to an {@code Args} object.
*
* @param key The key name.
- * @param value The value. (String or String [])
- * @return This Args set.
+ * @param value The value, as a {@code String:String} or
+ * {@code String:String[]}.
+ * @return This {@code Args} set.
*/
public Args add(String key, Object value) {
put(key, value);
@@ -69,30 +72,33 @@ public Args add(String key, Object value) {
}
/**
- * Creates a new Args instance that is empty.
+ * Creates a new empty instance of {@code Args}.
*
- * @return The Args instance.
+ * @return The {@code Args} instance.
*/
public static Args create() {
return new Args();
}
/**
- * Creates a new Args instance initialized with a single key/value pair.
+ * Creates a new {@code Args} instance and initializes it with a single
+ * key-value pair.
*
* @param key The key name.
- * @param value The value. (String or String[])
- * @return The Args instance.
+ * @param value The value, as a {@code String:String} or
+ * {@code String:String[]}.
+ * @return The {@code Args} instance.
*/
public static Args create(String key, Object value) {
return new Args(key, value);
}
/**
- * Creates a new Args instance initialized with a pre-existing hash map.
+ * Creates a new {@code Args} instance and initializes it with a
+ * pre-existing hash map.
*
* @param values The pre-existing hash map.
- * @return The Args instance.
+ * @return The {@code Args} instance.
*/
public static Args create(Map values) {
return values == null ? new Args() : new Args(values);
@@ -115,8 +121,8 @@ public static String encode(String value) {
}
/**
- * Encodes a hash map of String:String or String:String[] into a single UTF8
- * encoded string.
+ * 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.
@@ -125,7 +131,7 @@ public static String encode(Map args) {
return Args.create(args).encode();
}
- // Encode an argument with a list valued argument
+ // Encodes an argument with a list-valued argument.
private void
encodeValues(StringBuilder builder, String key, String[] values) {
key = encode(key);
@@ -138,9 +144,9 @@ public static String encode(Map args) {
}
/**
- * Encodes an Args instance into a UTF8 encoded string.
+ * Encodes an {@code Args} instance into a UTF8-encoded string.
*
- * @return The UTF8 encoded string.
+ * @return The UTF8-encoded string.
*/
public String encode() {
StringBuilder builder = new StringBuilder();
@@ -161,7 +167,7 @@ public String encode() {
}
/**
- * Returns the hash map value of a specific key, or the default value if
+ * Returns the hash-map value of a specific key, or the default value if
* the key is not found.
*
* @param args The hash map.
diff --git a/splunk/src/main/java/com/splunk/AtomEntry.java b/splunk/src/main/java/com/splunk/AtomEntry.java
new file mode 100644
index 00000000..1282d2d2
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/AtomEntry.java
@@ -0,0 +1,249 @@
+/*
+ * 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.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * The {@code AtomEntry} class represents an Atom {@code } element.
+ */
+public class AtomEntry extends AtomObject {
+ /** The value of the Atom entry's {@code } element. */
+ public String published;
+
+ /** The value of the Atom entry's {@code } element. */
+ public Record content;
+
+ /**
+ * Creates a new {@code AtomEntry} instance.
+ *
+ * @return A new {@code AtomEntry} instance.
+ */
+ static AtomEntry create() {
+ return new AtomEntry();
+ }
+
+ /**
+ * Creates a new {@code AtomEntry} instance based on a given stream.
+ * A few endpoints, such as {@code search/jobs/{sid}},
+ * return an Atom {@code } element as the root of the response.
+ *
+ * @param input The input stream.
+ * @return An {@code AtomEntry} instance representing the parsed stream.
+ */
+
+ public static AtomEntry parseStream(InputStream input) {
+ XMLStreamReader reader = createReader(input);
+
+ AtomEntry result = AtomEntry.parse(reader);
+
+ try {
+ reader.close();
+ }
+ catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Creates a new {@code AtomEntry} instance based on a given XML reader.
+ *
+ * @param reader The XML reader.
+ * @return An {@code AtomEntry} instance representing the parsed XML.
+ */
+ static AtomEntry parse(XMLStreamReader reader) {
+ AtomEntry entry = AtomEntry.create();
+ entry.load(reader, "entry");
+ return entry;
+ }
+
+ /**
+ * Initializes the current instance using the given XML reader.
+ *
+ * @param reader The XML reader.
+ */
+ @Override void init(XMLStreamReader reader) {
+ assert reader.isStartElement();
+
+ String name = reader.getLocalName();
+
+ if (name.equals("published")) {
+ this.published = parseText(reader);
+ }
+ else if (name.equals("content")) {
+ this.content = parseContent(reader);
+ }
+ else {
+ super.init(reader);
+ }
+ }
+
+ /**
+ * Parses the {@code } element of an Atom entry.
+ *
+ * @param reader The XML reader.
+ * @return A {@code Record} object containing the parsed values.
+ */
+ private Record parseContent(XMLStreamReader reader) {
+ assert isStartElement(reader, "content");
+
+ scan(reader);
+
+ // The content element should contain a single element
+
+ if (!isStartElement(reader, "dict"))
+ syntaxError(reader);
+
+ content = parseDict(reader);
+
+ if (!isEndElement(reader, "content"))
+ syntaxError(reader);
+
+ scan(reader); // Consume
+
+ return content;
+ }
+
+ /**
+ * Parses a {@code } content element and returns a {@code Record}
+ * object containing the parsed values.
+ *
+ * @param reader The {@code } element to parse.
+ * @return A {@code Record} object containing the parsed values.
+ */
+ private Record parseDict(XMLStreamReader reader) {
+ assert isStartElement(reader, "dict");
+
+ Record result = new Record();
+
+ scan(reader);
+ while (isStartElement(reader, "key")) {
+ String key = reader.getAttributeValue(null, "name");
+ Object value = parseValue(reader);
+ // Null values, the result of empty elements, are parsed as though
+ // they don't exist, making it easier for the client framework to
+ // supply more meaningful default values.
+ if (value != null) result.put(key, value);
+ }
+
+ if (!isEndElement(reader, "dict"))
+ syntaxError(reader);
+
+ scan(reader); // Consume
+
+ return result;
+ }
+
+ /**
+ * Parses a {@code } element and returns a {@code List} object
+ * containing the parsed values.
+ *
+ * @param reader The XML reader.
+ * @return A {@code List} object containing the parsed values.
+ */
+ private List parseList(XMLStreamReader reader) {
+ assert isStartElement(reader, "list");
+
+ List result = new ArrayList();
+
+ scan(reader);
+ while (isStartElement(reader, "item")) {
+ Object value = parseValue(reader);
+ result.add(value);
+ }
+
+ if (!isEndElement(reader, "list"))
+ syntaxError(reader);
+
+ scan(reader); // Consume
+
+ return result;
+ }
+
+ // Parses either a dict or list structure.
+ private Object parseStructure(XMLStreamReader reader) {
+ String name = reader.getLocalName();
+
+ if (name.equals("dict"))
+ return parseDict(reader);
+
+ if (name.equals("list"))
+ return parseList(reader);
+
+ syntaxError(reader);
+
+ return null; // Unreached
+ }
+
+ /**
+ * Parses the value contained by the element at the current cursor position
+ * of the given reader.
+ *
+ * Note: This function takes the parent element as its starting point
+ * so that it can correctly match the end element. The function takes the
+ * start element and its corresponding end element, then returns the
+ * contained value. The cursor is then located at the next element to be
+ * parsed.
+ *
+ * @param reader The XML reader to parse.
+ * @return An object containing the parsed values. If the source was a text
+ * value, the object is a {@code String}. If the source was a {@code }
+ * element, the object is a {@code Record}. If the source was a
+ * {@code } element, the object is a {@code List} object.
+ */
+ Object parseValue(XMLStreamReader reader) {
+ assert reader.isStartElement();
+
+ String name = reader.getLocalName();
+
+ scan(reader);
+
+ Object value;
+ switch (reader.getEventType()) {
+ case XMLStreamConstants.CHARACTERS:
+ value = reader.getText();
+ scan(reader); // Advance cursor
+ break;
+
+ case XMLStreamConstants.START_ELEMENT:
+ value = parseStructure(reader);
+ break;
+
+ case XMLStreamConstants.END_ELEMENT:
+ value = null; // Empty element
+ break;
+
+ default:
+ value = null;
+ syntaxError(reader);
+ }
+
+ if (!isEndElement(reader, name))
+ syntaxError(reader);
+
+ scan(reader); // Consume end element
+
+ return value;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/AtomFeed.java b/splunk/src/main/java/com/splunk/AtomFeed.java
new file mode 100644
index 00000000..27915701
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/AtomFeed.java
@@ -0,0 +1,115 @@
+/*
+ * 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.InputStream;
+import java.util.*;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+
+/**
+ * The {@code AtomFeed} class represents an Atom feed.
+ */
+public class AtomFeed extends AtomObject {
+ /** The list of Atom entries contained in this {@code AtomFeed} object. */
+ public ArrayList entries = new ArrayList();
+
+ /** The value of the Atom feed's {@code } element. */
+ public String itemsPerPage = null;
+
+ /** The value of the Atom feed's {@code } element. */
+ public String startIndex = null;
+
+ /** The value of the Atom feed's {@code } element. */
+ public String totalResults = null;
+
+ /**
+ * Creates a new {@code AtomFeed} instance.
+ *
+ * @return A new {@code AtomFeed} instance.
+ */
+ static AtomFeed create() {
+ return new AtomFeed();
+ }
+
+ /**
+ * Creates a new {@code AtomFeed} instance based on the given stream.
+ *
+ * @param input The input stream.
+ * @return An {@code AtomFeed} instance representing the parsed stream.
+ */
+ public static AtomFeed parseStream(InputStream input) {
+ XMLStreamReader reader = createReader(input);
+
+ AtomFeed result = AtomFeed.parse(reader);
+
+ try {
+ reader.close();
+ }
+ catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Creates a new {@code AtomFeed} instance based on a given XML element.
+ *
+ * @param input The XML stream.
+ * @return An {@code AtomFeed} instance representing the parsed element.
+ * @throws RuntimeException The runtime exception if a parse error occurs.
+ */
+ static AtomFeed parse(XMLStreamReader input) {
+ AtomFeed feed = AtomFeed.create();
+ feed.load(input, "feed");
+ return feed;
+ }
+
+ /**
+ * Initializes the current instance from a given XML element.
+ *
+ * @param reader The XML reader.
+ */
+ @Override void init(XMLStreamReader reader) {
+ assert reader.isStartElement();
+
+ String name = reader.getLocalName();
+
+ if (name.equals("entry")) {
+ AtomEntry entry = AtomEntry.parse(reader);
+ this.entries.add(entry);
+ }
+ else if (name.equals("messages")) {
+ parseEnd(reader);
+ }
+ else if (name.equals("totalResults")) {
+ this.totalResults = parseText(reader);
+ }
+ else if (name.equals("itemsPerPage")) {
+ this.itemsPerPage = parseText(reader);
+ }
+ else if (name.equals("startIndex")) {
+ this.startIndex = parseText(reader);
+ }
+ else {
+ super.init(reader);
+ }
+ }
+}
+
diff --git a/splunk/src/main/java/com/splunk/AtomObject.java b/splunk/src/main/java/com/splunk/AtomObject.java
new file mode 100644
index 00000000..67567134
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/AtomObject.java
@@ -0,0 +1,248 @@
+/*
+ * 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.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+
+/**
+ * The {@code AtomObject} class represents a generic Atom object. This class is
+ * a common base class shared by {@code AtomFeed} and {@code AtomEntry}.
+ */
+public class AtomObject {
+ /** The value of the Atom {@code } element. */
+ public String id;
+
+ /** The value of the {@code } elements in this {@code AtomObject}. */
+ public Map links = new HashMap();
+
+ /** The value of the Atom {@code } element. */
+ public String title;
+
+ /** The value of the Atom {@code } element. */
+ public String updated;
+
+ /**
+ * Instantiates the XMLStreamReader, advances to the root element and
+ * validates the root document structure. This initialization code is shared
+ * by the {@code AtomFeed} and {@code AtomEntry} parsers.
+ *
+ * @param input The input stream.
+ * @return An {@code XMLStreamReader} initialized reader, advanced to the
+ * first element of the document.
+ */
+ protected static XMLStreamReader createReader(InputStream input) {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+
+ // The Atom parser assumes that all adjacent text nodes are coalesced
+ factory.setProperty(XMLInputFactory.IS_COALESCING, true);
+ factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true);
+
+ XMLStreamReader reader;
+ try {
+ reader = factory.createXMLStreamReader(input);
+ }
+ catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ assert reader.getEventType() == XMLStreamConstants.START_DOCUMENT;
+
+ // Scan ahead to first element
+ scanTag(reader);
+
+ return reader;
+ }
+
+ /**
+ * Initialize a property of the current instance based on the given XML
+ * element.
+ *
+ * @param reader The XML reader.
+ */
+ void init(XMLStreamReader reader) {
+ assert reader.isStartElement();
+
+ String name = reader.getLocalName();
+
+ if (name.equals("id")) {
+ this.id = parseText(reader);
+ }
+ else if (name.equals("link")) {
+ String rel = reader.getAttributeValue(null, "rel");
+ String href = reader.getAttributeValue(null, "href");
+ this.links.put(rel, href);
+ parseEnd(reader);
+ }
+ else if (name.equals("title")) {
+ this.title = parseText(reader);
+ }
+ else if (name.equals("updated")) {
+ this.updated = parseText(reader);
+ }
+ else {
+ parseEnd(reader); // Ignore
+ }
+ }
+
+ /**
+ * Initializes the current instance from the given XML element by calling
+ * the {@code init} method on each child of the XML element.
+ *
+ * @param reader The XML reader.
+ */
+ void load(XMLStreamReader reader, String localName) {
+ assert isStartElement(reader, localName);
+
+ String name = reader.getLocalName();
+
+ scan(reader);
+ while (reader.isStartElement()) {
+ init(reader);
+ }
+
+ if (!isEndElement(reader, name))
+ syntaxError(reader);
+
+ scan(reader); // Consume the end element
+ }
+
+ /**
+ * Parses the element at the current cursor position and reads the
+ * corresponding end element.
+ *
+ * @param reader The XML reader.
+ */
+ protected void parseEnd(XMLStreamReader reader) {
+ scanEnd(reader); // Scan ahead to the end element
+ scan(reader); // Consume the end element
+ }
+
+ /**
+ * Parses and returns the text value of the element at the current cursor
+ * position and reads the corresponding end element.
+ *
+ * @param reader The XML reader.
+ * @return The element's text value.
+ */
+ protected String parseText(XMLStreamReader reader) {
+ assert reader.isStartElement();
+
+ String name = reader.getLocalName();
+
+ String value = getElementText(reader);
+
+ if (!isEndElement(reader, name))
+ syntaxError(reader);
+
+ scan(reader); // Consume the end element
+
+ return value;
+ }
+
+ //
+ // Lexical helpers
+ //
+
+ protected static String getElementText(XMLStreamReader reader) {
+ try {
+ return reader.getElementText();
+ }
+ catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ protected static boolean
+ isEndElement(XMLStreamReader reader, String localName) {
+ return reader.isEndElement()
+ && reader.getLocalName().equals(localName);
+ }
+
+ protected static boolean
+ isStartElement(XMLStreamReader reader, String localName) {
+ return reader.isStartElement()
+ && reader.getLocalName().equals(localName);
+ }
+
+ // Scan ahead to the next token, skipping whitespace
+ protected static void scan(XMLStreamReader reader) {
+ assert !reader.isWhiteSpace(); // current should never be white
+ try {
+ do {
+ reader.next();
+ }
+ while (reader.isWhiteSpace()); // Ignore whitespace
+ }
+ catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ // Scan ahead to the end element that matches the current start element.
+ // Note: function returns cursor located at matching end element.
+ protected static void scanEnd(XMLStreamReader reader) {
+ assert reader.isStartElement();
+
+ String name = reader.getLocalName();
+
+ while (true) {
+ scan(reader);
+
+ switch (reader.getEventType()) {
+ case XMLStreamConstants.CHARACTERS:
+ continue;
+
+ case XMLStreamConstants.START_ELEMENT:
+ scanEnd(reader);
+ continue;
+
+ case XMLStreamConstants.END_ELEMENT:
+ if (!reader.getLocalName().equals(name))
+ syntaxError(reader);
+ return;
+
+ default:
+ syntaxError(reader);
+ }
+ }
+ }
+
+ // Scan ahead until the next start tag.
+ protected static void scanTag(XMLStreamReader reader) {
+ try {
+ reader.nextTag();
+ }
+ catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ // Raises a Syntax error runtime exception
+ protected static void syntaxError(XMLStreamReader reader) {
+ Location location = reader.getLocation();
+ String where = location.toString();
+ String message = String.format("Syntax error @ %s", where);
+ throw new RuntimeException(message);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/BaseService.java b/splunk/src/main/java/com/splunk/BaseService.java
new file mode 100644
index 00000000..d311b13e
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/BaseService.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * Contains functionality common to Splunk Enterprise and Splunk Storm.
+ *
+ * This class is an implementation detail and is therefore SDK-private.
+ */
+abstract class BaseService extends HttpService {
+ protected BaseService() {
+ super();
+ }
+
+ protected BaseService(String host) {
+ super(host);
+ }
+
+ protected BaseService(String host, int port) {
+ super(host, port);
+ }
+
+ protected BaseService(String host, int port, String scheme) {
+ super(host, port, scheme);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/BooleanComparison.java b/splunk/src/main/java/com/splunk/BooleanComparison.java
new file mode 100644
index 00000000..8751db96
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/BooleanComparison.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2014 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;
+
+/**
+ * Comparisons on boolean valued fields.
+ */
+public enum BooleanComparison {
+ IS_NULL {
+ public String toString() { return "isNull"; }
+ },
+ IS_NOT_NULL {
+ public String toString() { return "isNotNull"; }
+ },
+ EQUALS {
+ public String toString() { return "="; }
+ },
+ IS {
+ public String toString() { return "is"; }
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/BooleanPivotColumnSplit.java b/splunk/src/main/java/com/splunk/BooleanPivotColumnSplit.java
new file mode 100644
index 00000000..66b096dd
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/BooleanPivotColumnSplit.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonObject;
+
+/**
+ * Represents a column split on a boolean valued field in a pivot.
+ */
+public class BooleanPivotColumnSplit extends PivotColumnSplit {
+ private final String trueLabel, falseLabel;
+
+ BooleanPivotColumnSplit(DataModelObject owner, String fieldName, String trueLabel, String falseLabel) {
+ super(owner, fieldName);
+ this.trueLabel = trueLabel;
+ this.falseLabel = falseLabel;
+ }
+
+ @Override
+ JsonObject toJson() {
+ JsonObject root = new JsonObject();
+ addCommonFields(root);
+
+ root.addProperty("trueLabel", trueLabel);
+ root.addProperty("falseLabel", falseLabel);
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/BooleanPivotFilter.java b/splunk/src/main/java/com/splunk/BooleanPivotFilter.java
new file mode 100644
index 00000000..3e08d6c0
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/BooleanPivotFilter.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Represents a filter on a boolean valued field in a pivot.
+ */
+public class BooleanPivotFilter extends PivotFilter {
+ private final BooleanComparison comparison;
+ private final boolean comparisonValue;
+
+ BooleanPivotFilter(DataModelObject dataModelObject, String fieldName,
+ BooleanComparison comparison, boolean comparisonValue) {
+ super(dataModelObject, fieldName);
+ if (dataModelObject.getField(fieldName).getType() != FieldType.BOOLEAN) {
+ throw new IllegalArgumentException("Field " + fieldName + " on the data model object was of type "
+ + dataModelObject.getField(fieldName).getType().toString() + ", expected boolean.");
+ }
+ this.comparison = comparison;
+ this.comparisonValue = comparisonValue;
+ }
+
+ @Override
+ JsonElement toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+
+ JsonObject filterRule = new JsonObject();
+ filterRule.add("comparator", new JsonPrimitive(this.comparison.toString()));
+ filterRule.add("compareTo", new JsonPrimitive(this.comparisonValue));
+
+ root.add("rule", filterRule);
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/BooleanPivotRowSplit.java b/splunk/src/main/java/com/splunk/BooleanPivotRowSplit.java
new file mode 100644
index 00000000..d68df895
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/BooleanPivotRowSplit.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Represents a row split on a boolean valued field in a pivot.
+ */
+public class BooleanPivotRowSplit extends PivotRowSplit {
+ private final String falseDisplayValue;
+ private final String trueDisplayValue;
+
+ BooleanPivotRowSplit(DataModelObject dataModelObject, String field, String label,
+ String trueDisplayValue, String falseDisplayValue) {
+ super(dataModelObject, field, label);
+ this.trueDisplayValue = trueDisplayValue;
+ this.falseDisplayValue = falseDisplayValue;
+ }
+
+ public String getTrueDisplayValue() { return this.trueDisplayValue; }
+ public String getFalseDisplayValue() { return this.falseDisplayValue; }
+
+ @Override
+ JsonElement toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+
+ root.add("trueLabel", new JsonPrimitive(this.trueDisplayValue));
+ root.add("falseLabel", new JsonPrimitive(this.falseDisplayValue));
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/CollectionArgs.java b/splunk/src/main/java/com/splunk/CollectionArgs.java
new file mode 100644
index 00000000..25fd35aa
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/CollectionArgs.java
@@ -0,0 +1,177 @@
+/*
+ * 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;
+
+/**
+ * The {@code CollectionArgs} class contains arguments for retrieving and
+ * listing entities from a collection, such as the number of entities to return
+ * and how to sort them.
+ */
+public class CollectionArgs extends Args {
+
+ /**
+ * Indicates whether to sort entries in ascending or descending order.
+ */
+ public static enum SortDirection {
+ /** Sort entries in ascending order. */
+ ASC("asc"),
+ /** Sort entries in descending order. */
+ DESC("desc");
+
+ private String value;
+
+ private SortDirection(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Indicates the sorting mode for entries.
+ */
+ public static enum SortMode {
+ /**
+ * If all values of the field are numbers, collate numerically.
+ * Otherwise, collate alphabetically.
+ */
+ AUTO("auto"),
+ /** Collate alphabetically. */
+ ALPHA("alpha"),
+ /** Collate alphabetically, case-sensitive. */
+ ALPHA_CASE("alpha_case"),
+ /** Collate numerically. */
+ NUM("num");
+
+ private String value;
+
+ private SortMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Class constructor.
+ */
+ public CollectionArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the app context in which to list the collection.
+ *
+ * @param app
+ * The app context in which to list the collection. A {@code null} value indicates no app context, and a value of {@code "-"} indicates an app wildcard.
+ */
+ public void setApp(String app) {
+ this.put("app", app);
+ }
+
+ /**
+ * Sets the owner context in which to list the collection.
+ *
+ * @param owner
+ * The owner context in which to list the collection. A value of {@code "-"} indicates a wildcard, and a {@code null} value indicates no owner context.
+ */
+ public void setOwner(String owner) {
+ this.put("owner", owner);
+ }
+
+ /**
+ * Sets the sharing context in which to list the collection.
+ *
+ * @param sharing
+ * The sharing context in which to list the collection. Valid values are "user", "app", "global", and "system".
+ */
+ public void setSharing(String sharing) {
+ this.put("sharing", sharing);
+ }
+
+ /**
+ * Sets the maximum number of entries to return.
+ *
+ * @param count
+ * The maximum number of entries to return. To return all entries, specify 0.
+ */
+ public void setCount(int count) {
+ this.put("count", count);
+ }
+
+ /**
+ * Sets the index of the first entry to return.
+ *
+ * @param offset
+ * The index of the first entry to return.
+ */
+ public void setOffset(int offset) {
+ this.put("offset", offset);
+ }
+
+ /**
+ * Sets a search query to filter the response. The response matches field values against the search query. For example, "foo" matches any object that has "foo" as a substring in a field, and "field_name=field_value" restricts the match to a single field.
+ *
+ * @param search
+ * A search query to filter the response.
+ */
+ public void setSearch(String search) {
+ this.put("search", search);
+ }
+
+ /**
+ * Sets the direction to sort entries.
+ *
+ * @param sortDirection
+ * The sorting order--ascending or descending.
+ */
+ public void setSortDirection(SortDirection sortDirection) {
+ this.put("sort_dir", sortDirection);
+ }
+
+ /**
+ * Sets the field to use for sorting.
+ *
+ * @param sortKey
+ * The field to sort by.
+ */
+ public void setSortKey(String sortKey) {
+ this.put("sort_key", sortKey);
+ }
+
+ /**
+ * Sets the mode to use for sorting.
+ *
+ * @param sortMode
+ * The collating sequence for sorting entries.
+ */
+ public void setSortMode(SortMode sortMode) {
+ this.put("sort_mode", sortMode);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk-sdk/com/splunk/sdk/Command.java b/splunk/src/main/java/com/splunk/Command.java
similarity index 76%
rename from splunk-sdk/com/splunk/sdk/Command.java
rename to splunk/src/main/java/com/splunk/Command.java
index 2772b2b2..4dbd39b6 100644
--- a/splunk-sdk/com/splunk/sdk/Command.java
+++ b/splunk/src/main/java/com/splunk/Command.java
@@ -14,7 +14,7 @@
* under the License.
*/
-package com.splunk.sdk;
+package com.splunk;
import java.io.BufferedReader;
import java.io.File;
@@ -23,7 +23,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.lang.reflect.*;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
@@ -33,7 +32,11 @@
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
-// Processes and capture command options and arguments
+/**
+ * This class serves as an example and is unsupported.
+ *
+ * Processes and capture command options and arguments
+ */
public class Command {
private String appName;
private Options rules = new Options();
@@ -44,16 +47,16 @@ public class Command {
// The parsed command line options (flags)
public HashMap opts = new HashMap();
- // Option fields
- public String app = null;
+ // Whether or not this is a help request
public Boolean help = false;
- public String host = "localhost";
- public String owner = null;
- public int port = 8089;
- public String password = null;
- public String scheme = "https";
- public String username = null;
+ public static final HashMap defaultValues = new HashMap();
+ {
+ defaultValues.put("scheme", "https");
+ defaultValues.put("host", "localhost");
+ defaultValues.put("port", 8089);
+ }
+
Command(String appName) {
this.appName = appName;
}
@@ -76,6 +79,7 @@ public Options getRules() {
}
// Initialize with default Splunk command options.
+ @SuppressWarnings("static-access") // OptionBuilder API requires this
public Command init() {
rules.addOption("h", "help", false, "Display this help message");
rules.addOption(null, "host", true, "Host name (default localhost)");
@@ -89,6 +93,8 @@ public Command init() {
rules.addOption(null, "password", true, "Password to login with");
rules.addOption(null, "app", true, "App/namespace context");
rules.addOption(null, "owner", true, "Owner/user context");
+ // This is here only for compatibility with the JavaScript SDK's .splunkrc.
+ rules.addOption(null, "version", true, "Version (irrelevant for Java)");
return this;
}
@@ -97,6 +103,7 @@ public Command addRule(String name, String description) {
return this;
}
+ @SuppressWarnings("static-access") // OptionBuilder API requires this
public Command addRule(String name, Class argType, String description) {
rules.addOption(
OptionBuilder
@@ -110,28 +117,36 @@ public Command addRule(String name, Class argType, String description) {
// Load a file of options and arguments
public Command load(String path) {
- FileReader fileReader;
+ ArrayList argList = new ArrayList();
+
try {
- fileReader = new FileReader(path);
- }
- catch (FileNotFoundException e) { return this; }
-
- ArrayList argList = new ArrayList(4);
- BufferedReader reader = new BufferedReader(fileReader);
- while (true) {
- String line;
+ FileReader fileReader = new FileReader(path);
try {
- line = reader.readLine();
+ BufferedReader reader = new BufferedReader(fileReader);
+ while (true) {
+ String line;
+ line = reader.readLine();
+ if (line == null)
+ break;
+ if (line.startsWith("#"))
+ continue;
+ line = line.trim();
+ if (line.length() == 0)
+ continue;
+ if (!line.startsWith("-"))
+ line = "--" + line;
+ argList.add(line);
+ }
}
- catch (IOException e) { return this; }
- if (line == null) break;
- if (line.startsWith("#")) continue;
- line = line.trim();
- if (line.length() == 0) continue;
- if (!line.startsWith("-"))
- line = "--" + line;
- argList.add(line);
+ finally {
+ fileReader.close();
+ }
+ }
+ catch (IOException e) {
+ error(e.getMessage());
+ return this;
}
+
parse(argList.toArray(new String[argList.size()]));
return this;
}
@@ -153,7 +168,7 @@ public Command parse(String[] argv) {
for (Option option : cmdline.getOptions()) {
String name = option.getLongOpt();
Object value = option.getValue();
-
+
// Figure out the type of the option and convert the value.
if (!option.hasArg()) {
// If it has no arg, then its implicitly boolean and presence
@@ -180,12 +195,12 @@ else if (type == Integer.class) {
// corresponding option value in order to provide simplified
// access to command options.
try {
- Field field = this.getClass().getField(name);
+ java.lang.reflect.Field field = this.getClass().getField(name);
field.set(this, value);
}
catch (NoSuchFieldException e) { continue; }
catch (IllegalAccessException e) {
- throw new RuntimeException(e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
}
}
@@ -221,8 +236,8 @@ public static Command splunk(String appName) {
// Load the default options file (.splunkrc) if it exists
public Command splunkrc() {
- String home = System.getProperty("user.home");
- load(home + File.separator + ".splunkrc");
+ this.opts.putAll(defaultValues);
+ load(System.getProperty("user.home") + File.separator + ".splunkrc");
return this;
}
}
diff --git a/splunk/com/splunk/ConfCollection.java b/splunk/src/main/java/com/splunk/ConfCollection.java
similarity index 52%
rename from splunk/com/splunk/ConfCollection.java
rename to splunk/src/main/java/com/splunk/ConfCollection.java
index 04ecc704..cc2cbf8d 100644
--- a/splunk/com/splunk/ConfCollection.java
+++ b/splunk/src/main/java/com/splunk/ConfCollection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -19,7 +19,8 @@
import java.util.Map;
/**
- * Representation of a collection of configurations.
+ * The {@code ConfCollection} class represents a collection of configuration
+ * files.
*/
public class ConfCollection
extends ResourceCollection>
@@ -27,28 +28,40 @@ public class ConfCollection
/**
* Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
*/
ConfCollection(Service service) {
super(service, "properties", EntityCollection.class);
}
/**
- * Creates a config.
+ * Class constructor.
*
- * @param name The new config name.
- * @return The new config.
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them. See {@link CollectionArgs}.
+ */
+ ConfCollection(Service service, Args args) {
+ super(service, "properties", EntityCollection.class, args);
+ }
+
+ /**
+ * Creates a new stanza in the current configuration file.
+ *
+ * @param name The name of the stanza to create.
+ * @return The name of the new stanza.
*/
public EntityCollection create(String name) {
return create(name, null);
}
/**
- * Creates a new config.
+ * Creates a new stanza in the current configuration file with attributes.
*
- * @param name The new config name.
- * @param args Optional arguments.
- * @return the new config.
+ * @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 create(String name, Map args) {
args = Args.create(args).add("__conf", name);
@@ -56,12 +69,13 @@ public EntityCollection create(String name, Map args) {
invalidate();
return get(name);
}
-
+
/**
- * Returns This config's endpoint path.
+ * Returns the endpoint path for this configuration stanza.
*
- * @param entry The atom representation of this entry.
- * @return This config's endpoint path.
+ * @param entry The {@code AtomEntry} representation of this entry.
+ * @return This stanza's endpoint path in the format
+ * "/servicesNS/{user}/{app}/configs/conf-{file}/{stanza}".
*/
@Override protected String itemPath(AtomEntry entry) {
return String.format("configs/conf-%s", entry.title);
diff --git a/splunk/src/main/java/com/splunk/DataModel.java b/splunk/src/main/java/com/splunk/DataModel.java
new file mode 100644
index 00000000..ce42f6f9
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModel.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2014 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 com.google.gson.*;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * DataModel represents a data model on the server. Data models contain
+ * data model objects, which specify structured views on Splunk data.
+ */
+public class DataModel extends Entity {
+ private final static JsonParser jsonParser = new JsonParser();
+ private final static Gson gson = new Gson();
+
+ private static final String ACCELERATION_LABEL = "acceleration";
+ private static final String MODEL_NAME_LABEL = "modelName";
+ private static final String DISPLAY_NAME_LABEL = "displayName";
+ private static final String DESCRIPTION_LABEL = "description";
+ private static final String RAW_JSON_LABEL = "description"; // Yes, this is insane.
+
+ // Human readable description, as opposed to the raw JSON, which is also called 'description'
+ private String description;
+
+ private Map objects;
+ private boolean accelerationEnabled;
+ private String earliestAcceleratedTime;
+ private String accelerationCronSchedule;
+ private boolean manualRebuilds;
+
+ DataModel(Service service, String path) {
+ super(service, path);
+ // The data provided by the collection is incomplete. Go ahead and refresh so we don't
+ // have to worry about it.
+ this.refresh();
+ }
+
+ /**
+ * Returns whether there is an object of the given name in this data model.
+ *
+ * @param name Name of the object to check for.
+ * @return true if there is an object with that name; false otherwise.
+ */
+ public boolean containsObject(String name) {
+ return this.objects.containsKey(name);
+ }
+
+ /**
+ * Retrieve an object by name from this data model.
+ *
+ * @param name Name of the object to retrieve.
+ * @return a DataModelObject if there is such an object; null otherwise.
+ */
+ public DataModelObject getObject(String name) {
+ return this.objects.get(name);
+ }
+
+ /**
+ * @return a collection of all objects in this data model.
+ */
+ public Collection getObjects() {
+ return Collections.unmodifiableCollection(objects.values());
+ }
+
+ /**
+ * Returns the tsidx namespace which holds global acceleration events for this
+ * data model. The namespace will be returned whether acceleration is enabled
+ * or not.
+ *
+ * @return The tsidx namespace for global acceleration of this data model.
+ */
+ public String getAccelerationNamespace() {
+ // For the moment, the acceleration namespace for global acceleration of
+ // data models is the name of the data model.
+ return getName();
+ }
+
+ /**
+ * @return whether global acceleration is enabled for this data model.
+ */
+ public boolean isAccelerated() {
+ return this.accelerationEnabled;
+ }
+
+ /**
+ * @return A human readable description of this data model.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * @return The raw JSON describing this data model and its objects.
+ */
+ public String getRawJson() {
+ return getString(RAW_JSON_LABEL);
+ }
+
+ /**
+ * @return the human readable name of this data model.
+ */
+ public String getDisplayName() {
+ return getString(DISPLAY_NAME_LABEL);
+ }
+
+ @Override
+ Entity load(AtomObject value) {
+ Entity result = super.load(value);
+ // After loading the Atom entity as we would for any other Splunk entity,
+ // we have to parse the JSON description of the data model and its acceleration
+ // status.
+ parseDescription(getString(RAW_JSON_LABEL));
+ parseAcceleration(getString(ACCELERATION_LABEL));
+ return result;
+ }
+
+ /**
+ * Parse the JSON returned from splunkd describing this data model.
+ *
+ * This method writes the results into fields of this object.
+ *
+ * @param input a String containing JSON.
+ */
+ private void parseDescription(String input) {
+ objects = new HashMap();
+
+ JsonElement rootElement = jsonParser.parse(input);
+
+ for (Entry entry : rootElement.getAsJsonObject().entrySet()) {
+ if (entry.getKey().equals(MODEL_NAME_LABEL)) {
+ content.put(MODEL_NAME_LABEL, entry.getValue().getAsString());
+ } else if (entry.getKey().equals(DISPLAY_NAME_LABEL)) {
+ content.put(DISPLAY_NAME_LABEL, entry.getValue().getAsString());
+ } else if (entry.getKey().equals(DESCRIPTION_LABEL)) {
+ description = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("objects")) {
+ JsonArray objectArray = entry.getValue().getAsJsonArray();
+ for (JsonElement object : objectArray) {
+ DataModelObject dmo = DataModelObject.parse(this, object);
+ objects.put(dmo.getName(), dmo);
+ }
+ } else {
+ // Allow new keys without complaining
+ }
+ }
+ }
+
+ /**
+ * Parse the acceleration description from splunkd of this data model.
+ *
+ * This method writes the results into fields of this object.
+ *
+ * @param input a string containing JSON.
+ */
+ private void parseAcceleration(String input) {
+ JsonElement rootElement = jsonParser.parse(input);
+
+ for (Entry entry : rootElement. getAsJsonObject().entrySet()) {
+ if (entry.getKey().equals("enabled")) {
+ // API is broken in 6.1. It returns 1 instead of true (but does return false).
+ if (((JsonPrimitive)entry.getValue()).isBoolean()) {
+ accelerationEnabled = entry.getValue().getAsBoolean();
+ } else if (((JsonPrimitive)entry.getValue()).isNumber()) {
+ accelerationEnabled = entry.getValue().getAsInt() != 0;
+ } else {
+ throw new RuntimeException("splunkd returned an unknown value " + entry.getValue().toString() +
+ " for whether acceleration is enabled.");
+ }
+ } else if (entry.getKey().equals("earliest_time")) {
+ earliestAcceleratedTime = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("cron_schedule")) {
+ accelerationCronSchedule = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("manual_rebuilds")) {
+ if (((JsonPrimitive)entry.getValue()).isBoolean()) {
+ manualRebuilds = entry.getValue().getAsBoolean();
+ } else if (((JsonPrimitive)entry.getValue()).isNumber()) {
+ manualRebuilds = entry.getValue().getAsInt() != 0;
+ } else {
+ throw new RuntimeException("splunkd returned an unknown value " + entry.getValue().toString() +
+ " for whether manual_rebuilds is enabled.");
+ }
+ } else {
+ // Allow new keys without complaining
+ }
+ }
+ }
+
+ /**
+ * Enable or disable global acceleration on this data model.
+ *
+ * @param enabled true enabled, false disables.
+ */
+ public void setAcceleration(boolean enabled) {
+ this.accelerationEnabled = enabled;
+ toUpdate.put("enabled", enabled);
+ }
+
+ /**
+ * Return the earliest time of the window over which the data model is accelerated.
+ *
+ * Times are represented relative to now, given by a minus sign, a number, and a
+ * suffix indicating the time unit (e.g., "-2mon", "-1day").
+ *
+ * @return a string representing the earliest accelerated time.
+ */
+ public String getEarliestAcceleratedTime() {
+ return earliestAcceleratedTime;
+ }
+
+ /**
+ * Set the size of the window (from the specified earliest time to now) over
+ * which the data model should be accelerated.
+ *
+ * Times are represented relative to now, given by a minus sign, a number, and a
+ * suffix indicating the time unit (e.g., "-2mon", "-1day").
+ *
+ * @param earliestAcceleratedTime a string specifying a time.
+ */
+ public void setEarliestAcceleratedTime(String earliestAcceleratedTime) {
+ this.earliestAcceleratedTime = earliestAcceleratedTime;
+ toUpdate.put("earliest_time", earliestAcceleratedTime);
+ }
+
+ /**
+ * Return the cron schedule on which the cached data for acceleration should be
+ * updated.
+ *
+ * @return a string containing a crontab style schedule specification.
+ */
+ public String getAccelerationCronSchedule() {
+ return accelerationCronSchedule;
+ }
+
+ /**
+ * Set the cron schedule on which the cached data for the acceleration should
+ * be updated.
+ *
+ * @param accelerationCronSchedule a crontab style schedule to use.
+ */
+ public void setAccelerationCronSchedule(String accelerationCronSchedule) {
+ this.accelerationCronSchedule = accelerationCronSchedule;
+ toUpdate.put("cron_schedule", accelerationCronSchedule);
+ }
+
+ /**
+ * This setting prevents outdated summaries from being rebuilt by the
+ * 'summarize' command.
+ *
+ * @return whether manual rebuilds are enabled for this data model.
+ */
+ public boolean isManualRebuilds() {
+ return this.manualRebuilds;
+ }
+
+ /**
+ * Enable or disable manual rebuilds on this data model.
+ *
+ * @param enabled true enabled, false disables.
+ */
+ public void setManualRebuilds(boolean enabled) {
+ this.manualRebuilds = enabled;
+ toUpdate.put("manual_rebuilds", enabled);
+ }
+
+ @Override
+ public void update() {
+ // We have to do some munging on the acceleration fields to pass them as JSON
+ // to the server.
+ Map accelerationMap = new HashMap();
+ for (String key : new String[] {"enabled", "earliest_time", "cron_schedule", "manual_rebuilds"}) {
+ if (toUpdate.containsKey(key)) {
+ accelerationMap.put(key, toUpdate.get(key));
+ toUpdate.remove(key);
+ }
+ }
+
+ if (!accelerationMap.isEmpty()) {
+ toUpdate.put("acceleration", gson.toJson(accelerationMap));
+ }
+
+ // Now update like we would any other entity.
+ super.update();
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelArgs.java b/splunk/src/main/java/com/splunk/DataModelArgs.java
new file mode 100644
index 00000000..a9d0fb7a
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelArgs.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 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;
+
+/**
+ * Class representing arguments to creating a data model.
+ *
+ * At the moment this is a very minimal class, supporting only the
+ * description field for writing raw JSON to the server.
+ */
+public class DataModelArgs extends Args {
+ public String getRawJsonDescription() { return (String) get("description"); }
+ public void setRawJsonDescription(String rawJson) { put("description", rawJson); }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelCalculation.java b/splunk/src/main/java/com/splunk/DataModelCalculation.java
new file mode 100644
index 00000000..499c0584
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelCalculation.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * Abstract class specifying a calculation on a data model object.
+ */
+public abstract class DataModelCalculation {
+ private final String[] ownerLineage;
+ private final String calculationID;
+ private final Map generatedFields;
+ private final String comment;
+ private final boolean editable;
+
+ protected DataModelCalculation(String[] ownerLineage, String calculationID,
+ Map generatedFields, String comment, boolean editable) {
+ this.ownerLineage = ownerLineage;
+ this.calculationID = calculationID;
+ this.generatedFields = generatedFields;
+ this.comment = comment;
+ this.editable = editable;
+ }
+
+ /**
+ * @return the ID of this calculation.
+ */
+ public String getCalculationID() { return this.calculationID; }
+
+ /**
+ * @param fieldName Name of the field to fetch.
+ * @return whether this calculation generated a field of the given name.
+ */
+ public boolean containsGeneratedField(String fieldName) {
+ return this.generatedFields.containsKey(fieldName);
+ }
+
+ /**
+ * @return a collection of the fields this calculation generates.
+ */
+ public Collection getGeneratedFields() {
+ return Collections.unmodifiableCollection(this.generatedFields.values());
+ }
+
+ /**
+ * @param fieldName Name of the field to fetch.
+ * @return a DataModelField object.
+ */
+ public DataModelField getGeneratedField(String fieldName) { return this.generatedFields.get(fieldName); }
+
+ /**
+ * @return the comment on this calculation (if one is specified) or null.
+ */
+ public String getComment() { return this.comment; }
+
+ /**
+ * Returns the name of the object on which this calculation is defined.
+ * That need not be the one you accessed it from, as it may be inherited from
+ * another data model object.
+ *
+ * @return The name of the object on which this calculation is defined.
+ */
+ public String getOwner() { return this.ownerLineage[this.ownerLineage.length-1]; }
+
+ /**
+ * Return the lineage of the data model object on which this calculation is
+ * defined, starting with the most remote ancestor and ending with the data model object
+ * on which this calculation is defined.
+ *
+ * @return an array of the names of data model objects.
+ */
+ public String[] getLineage() { return this.ownerLineage; }
+
+ /**
+ * @return whether this calculation can be edited, or it is a system defined calculation.
+ */
+ public boolean isEditable() { return this.editable; }
+
+ static DataModelCalculation parse(JsonElement json) {
+ String type = null;
+ String calculationId = null;
+ List lookupInputs =
+ new ArrayList();
+ String comment = null;
+ String expression = null;
+ String lookupName = null;
+ String lookupField = null; // We need lookupField and inputField to handle the case in Splunk 6.0
+ String inputField = null; // where there is only one entry, and it's not in an array.
+ String[] owner = new String[0]; // Should always be set below
+ boolean editable = false;
+ Map outputFields = new HashMap();
+
+ String key;
+ for (Entry entry : json.getAsJsonObject().entrySet()) {
+ key = entry.getKey();
+ if (key.equals("calculationType")) {
+ type = entry.getValue().getAsString().toLowerCase();
+ } else if (key.equals("calculationID")) {
+ calculationId = entry.getValue().getAsString();
+ } else if (key.equals("outputFields")) {
+ for (JsonElement e : entry.getValue().getAsJsonArray()) {
+ DataModelField f = DataModelField.parse(e.getAsJsonObject());
+ outputFields.put(f.getName(), f);
+ }
+ } else if (key.equals("lookupInputs")) {
+ for (JsonElement lookupInputJsonElement : entry.getValue().getAsJsonArray()) {
+ if (!(lookupInputJsonElement instanceof JsonObject)) {
+ throw new RuntimeException("Expected a JSON object for lookupInput entry.");
+ }
+ JsonObject lookupInputJson = (JsonObject)lookupInputJsonElement;
+ LookupDataModelCalculation.LookupFieldMapping mapping = new LookupDataModelCalculation.LookupFieldMapping();
+ mapping.inputField = lookupInputJson.get("inputField").getAsString();
+ mapping.lookupField = lookupInputJson.get("lookupField").getAsString();
+ lookupInputs.add(mapping);
+ }
+ } else if (key.equals("inputField")) {
+ inputField = entry.getValue().getAsString();
+ } else if (key.equals("comment")) {
+ comment = entry.getValue().getAsString();
+ } else if (key.equals("expression")) {
+ expression = entry.getValue().getAsString();
+ } else if (key.equals("lookupName")) {
+ lookupName = entry.getValue().getAsString();
+ } else if (key.equals("lookupField")) {
+ lookupField = entry.getValue().getAsString();
+ } else if (key.equals("owner")) {
+ owner = entry.getValue().getAsString().split("\\.");
+ } else if (key.equals("editable")) {
+ editable = entry.getValue().getAsBoolean();
+ }
+ }
+
+ DataModelCalculation c;
+ if (type.equals("lookup")) {
+ c = new LookupDataModelCalculation(owner, calculationId, outputFields, comment, editable, lookupName, lookupInputs);
+ } else if (type.equals("geoip")) {
+ c = new GeoIPDataModelCalculation(owner, calculationId, outputFields, comment, editable, inputField);
+ } else if (type.equals("eval")) {
+ c = new EvalDataModelCalculation(owner, calculationId, outputFields, comment, editable, expression);
+ } else if (type.equals("rex")) {
+ c = new RegexpDataModelCalculation(owner, calculationId, outputFields, comment, editable, inputField, expression);
+ } else {
+ throw new IllegalStateException("Unknown calculation type: " + type);
+ }
+
+ return c;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelCollection.java b/splunk/src/main/java/com/splunk/DataModelCollection.java
new file mode 100644
index 00000000..dfad8544
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelCollection.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2014 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.Map;
+
+public class DataModelCollection extends EntityCollection {
+ DataModelCollection(Service service) {
+ super(service, "datamodel/model", DataModel.class);
+ this.refreshArgs.put("concise", "0");
+ }
+
+ /**
+ * Creates an entity in this collection.
+ *
+ * @param name The name of the entity.
+ * @return The entity.
+ */
+ @Override
+ public DataModel create(String name) {
+ return create(name, (Map)null);
+ }
+
+ /**
+ * 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);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelConstraint.java b/splunk/src/main/java/com/splunk/DataModelConstraint.java
new file mode 100644
index 00000000..7f7126b4
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelConstraint.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import java.util.Map.Entry;
+
+/**
+ * Represents a constraint on a data model object or a field on a data model object.
+ */
+public class DataModelConstraint {
+ private String owner;
+ private String query;
+
+ private DataModelConstraint() {
+ }
+
+ /**
+ * @return The Splunk search query this constraint specifies.
+ */
+ public String getQuery() { return this.query; }
+
+
+ /**
+ * @return The DataModelObject that owns this field.
+ */
+ public String getOwner() { return this.owner; }
+
+ /**
+ * Parse a DataModelConstraint object out of JSON.
+ *
+ * @param json JsonElement to parse.
+ * @return a DataModelConstraint object.
+ */
+ static DataModelConstraint parse(JsonElement json) {
+ JsonObject jsonObject = json.getAsJsonObject();
+ DataModelConstraint constraint = new DataModelConstraint();
+
+ for (Entry e : jsonObject.entrySet()) {
+ if (e.getKey().equals("owner")) {
+ constraint.owner = e.getValue().getAsString();
+ } else if (e.getKey().equals("search")) {
+ constraint.query = e.getValue().getAsString();
+ }
+ }
+
+ return constraint;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelField.java b/splunk/src/main/java/com/splunk/DataModelField.java
new file mode 100644
index 00000000..d83dca1c
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelField.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+
+import java.util.Map.Entry;
+
+/**
+ * Represents a field of a data model object.
+ */
+public class DataModelField {
+ private String[] ownerLineage;
+ private String name;
+ private FieldType type;
+ private boolean required;
+ private boolean multivalued;
+ private boolean hidden;
+ private String displayName;
+ private String comment;
+ private boolean editable;
+ private String fieldSearch;
+
+ private DataModelField() {}
+
+ /**
+ * @return a search query fragment for this field.
+ */
+ public String getFieldSearch() { return this.fieldSearch; }
+
+ /**
+ * @return The name of this field.
+ */
+ public String getName() { return this.name; };
+
+ /**
+ * Return the name of the data model object on which this field is defined. That need not
+ * be the data model object you accessed it from. It can be one of its ancestors.
+ *
+ * @return The name of the DataModelObject that owns this field.
+ */
+ public String getOwnerName() { return this.ownerLineage[this.ownerLineage.length-1]; }
+
+ /**
+ * Return the lineage of the data model object on which this field is defined. That need not
+ * be the data model object you accessed it from. It can be one of its ancestors.
+ *
+ * @return An array of names of DataModelObjects representing the lineage of this field's owner.
+ */
+ public String[] getOwnerLineage() { return this.ownerLineage; }
+
+ /**
+ * @return The type of this field.
+ */
+ public FieldType getType() { return this.type; }
+
+ /**
+ * Some fields are part of system objects such as BaseEvent or are part
+ * of the structure of the object, such as a field with the same name
+ * as the object. Those fields cannot be edited. This method returns
+ * whether the field is one of these protected fields.
+ *
+ * @return whether this field can be edited.
+ */
+ public boolean isEditable() { return editable; }
+
+ /**
+ * @return whether this field is required on events in the object.
+ */
+ public boolean isRequired() { return required; }
+
+ /**
+ * @return whether this field is can be multivalued.
+ */
+ public boolean isMultivalued() { return multivalued; }
+
+ /**
+ * @return whether this field should be displayed in a data model UI.
+ */
+ public boolean isHidden() { return hidden; }
+
+ /**
+ * @return a human readable name for this field.
+ */
+ public String getDisplayName() { return displayName; }
+
+ /**
+ * @return a comment on this field (if there is one), or null.
+ */
+ public String getComment() { return comment; }
+
+ public static DataModelField parse(JsonElement fieldJson) {
+ DataModelField field = new DataModelField();
+
+ for (Entry entry : fieldJson.getAsJsonObject().entrySet()) {
+ if (entry.getKey().equals("fieldName")) {
+ field.name = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("owner")) {
+ field.ownerLineage = entry.getValue().getAsString().split("\\.");
+ } else if (entry.getKey().equals("type")) {
+ field.type = FieldType.parseType(entry.getValue().getAsString());
+ } else if (entry.getKey().equals("required")) {
+ field.required = entry.getValue().getAsBoolean();
+ } else if (entry.getKey().equals("multivalue")) {
+ field.multivalued = entry.getValue().getAsBoolean();
+ } else if (entry.getKey().equals("hidden")) {
+ field.hidden = entry.getValue().getAsBoolean();
+ } else if (entry.getKey().equals("displayName")) {
+ field.displayName = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("comment")) {
+ //Before Splunk 7, comment value was just a string but now, its JSON ("comment": {"description": "The body of a message."})
+ if(entry.getValue().isJsonObject()) {
+ field.comment = entry.getValue().getAsJsonObject().get("description").getAsString();
+ } else {
+ field.comment = entry.getValue().getAsString();
+ }
+ } else if (entry.getKey().equals("editable")) {
+ field.editable = entry.getValue().getAsBoolean();
+ } else if (entry.getKey().equals("fieldSearch")) {
+ field.fieldSearch = entry.getValue().getAsString();
+ }
+ }
+
+ return field;
+ }
+}
+
diff --git a/splunk/src/main/java/com/splunk/DataModelObject.java b/splunk/src/main/java/com/splunk/DataModelObject.java
new file mode 100644
index 00000000..75c84d88
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelObject.java
@@ -0,0 +1,394 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * DataModelObject represents one of the structured views in a data model.
+ */
+public class DataModelObject {
+ private DataModel model;
+ private String name;
+ private String[] lineage;
+ private String displayName;
+ private String parentName;
+
+ private Map autoextractedFields;
+ private Collection constraints;
+ private Map calculations;
+
+ protected DataModelObject(DataModel model) {
+ this.model = model;
+ }
+
+ /**
+ * Checks whether there is a field with the given name in this
+ * data model object.
+ *
+ * @param fieldName name of the field to check for.
+ * @return true if there is such a field; false otherwise.
+ */
+ public boolean containsField(String fieldName) {
+ if (autoextractedFields.containsKey(fieldName)) {
+ return true;
+ }
+ for (DataModelCalculation c : calculations.values()) {
+ if (c.containsGeneratedField(fieldName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Local acceleration is tsidx acceleration of a data model object that is handled
+ * manually by a user. You create a job which generates an index, and then use that
+ * index in your pivots on the data model object.
+ *
+ * The namespace created by the job is 'sid={sid}' where {sid} is the job's sid. You
+ * would use it in another job by starting your search query with
+ *
+ * | tstats ... from sid={sid} | ...
+ *
+ * The tsidx index created by this job is deleted when the job is garbage collected
+ * by Splunk.
+ *
+ * It is the user's responsibility to manage this job, including cancelling it.
+ *
+ * @return a Job writing a tsidx index.
+ */
+ public Job createLocalAccelerationJob() {
+ return createLocalAccelerationJob(null);
+ }
+
+ /**
+ * Local acceleration is tsidx acceleration of a data model object that is handled
+ * manually by a user. You create a job which generates an index, and then use that
+ * index in your pivots on the data model object.
+ *
+ * The namespace created by the job is 'sid={sid}' where {sid} is the job's sid. You
+ * would use it in another job by starting your search query with
+ *
+ * | tstats ... from sid={sid} | ...
+ *
+ * The tsidx index created by this job is deleted when the job is garbage collected
+ * by Splunk.
+ *
+ * It is the user's responsibility to manage this job, including cancelling it.
+ *
+ * @param earliestTime A time modifier (e.g., "-2w") setting the earliest time to index.
+ * @return a Job writing a tsidx index.
+ */
+ public Job createLocalAccelerationJob(String earliestTime) {
+ String query = "| datamodel " + this.model.getName() + " " +
+ this.getName() + " search | tscollect";
+ JobArgs args = new JobArgs();
+ if (earliestTime != null) {
+ args.setEarliestTime(earliestTime);
+ }
+ return this.model.getService().search(query, args);
+ }
+
+ /**
+ * Return the calculations done by this data model object to produce fields.
+ *
+ * Each calculation has a unique ID assigned to it by splunkd, which is the key
+ * in the returned map. For most purposes you will probably only want the values.
+ *
+ * @return a map of calculation IDs to DataModelCalculation objects.
+ */
+ public Map getCalculations() {
+ return Collections.unmodifiableMap(this.calculations);
+ }
+
+ /**
+ * Fetch a calculation by its unique ID.
+ *
+ * @param calculationId a splunkd assigned unique ID for this calculation.
+ * @return a DataModelCalculation object.
+ */
+ public DataModelCalculation getCalculation(String calculationId) {
+ return this.calculations.get(calculationId);
+ }
+
+ /**
+ * @return a collection of the constraints limiting events that will appear in this data model object.
+ */
+ public Collection getConstraints() {
+ return Collections.unmodifiableCollection(this.constraints);
+ }
+
+ /**
+ * Fetch the data model on which this object is defined.
+ *
+ * @return A DataModel instance containing this object.
+ */
+ public DataModel getDataModel() {
+ return this.model;
+ }
+
+ /**
+ * @return the human readable name of this data model object.
+ */
+ public String getDisplayName() {
+ return this.displayName;
+ }
+
+ /**
+ * Fetch a single field of a given name from this data model object.
+ *
+ * @param fieldName Name of the field to fetch.
+ * @return A DataModelField object, or null if there is no field of the given name.
+ */
+ public DataModelField getField(String fieldName) {
+ if (autoextractedFields.containsKey(fieldName)) {
+ return autoextractedFields.get(fieldName);
+ }
+ for (DataModelCalculation c : this.calculations.values()) {
+ if (c.containsGeneratedField(fieldName)) {
+ return c.getGeneratedField(fieldName);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get a collection of objects specifying all the fields that were automatically extracted
+ * from events (as opposed to generated by calculations in a data model).
+ *
+ * @return a collection of DataModelField objects.
+ */
+ public Collection getAutoExtractedFields() {
+ return Collections.unmodifiableCollection(autoextractedFields.values());
+ }
+
+ /**
+ * Return all the fields, whether input or created by calculations.
+ * @return a collection of DataModelField objects.
+ */
+ public Collection getFields() {
+ Collection fields = new ArrayList();
+ fields.addAll(this.autoextractedFields.values());
+ for (DataModelCalculation c : this.calculations.values()) {
+ fields.addAll(c.getGeneratedFields());
+ }
+ return fields;
+ }
+
+ public String getQuery() {
+ return "| datamodel " + this.getDataModel().getName() + " " + this.getName() + " search";
+ }
+
+ /**
+ * @return Splunk's identifier for this data model object.
+ */
+ public String getName() { return this.name; }
+
+ /**
+ * Data model objects can inherit from other data model objects
+ * in the same data model (or from a couple of global base objects
+ * such as BaseEvent and BaseTransaction). The lineage is a list of
+ * data model object names tracing this inheritance, starting with the
+ * most remote ancestor and ending with this object.
+ *
+ * @return An array of names, starting with this object's name, followed by
+ * the names up the hierarchy.
+ */
+ public String[] getLineage() { return this.lineage; }
+
+ /**
+ * Returns the name of the parent of this object.
+ *
+ * @return a String giving the name.
+ */
+ public String getParentName() {
+ return this.parentName;
+ }
+
+ /**
+ * @return the data model object this one inherits from if it is a user defined data model object
+ * in the same data model; otherwise returns null (for example if the data model object inherits from BaseEvent
+ * or BaseTransaction).
+ */
+ public DataModelObject getParent() {
+ return this.getDataModel().getObject(this.parentName);
+ }
+
+ /**
+ * Create a PivotSpecification on this data model object.
+ *
+ * @return a PivotSpecification instance.
+ */
+ public PivotSpecification createPivotSpecification() {
+ return new PivotSpecification(this);
+ }
+
+ /**
+ * Start a job that fetches all the events of this data model object.
+ *
+ * @return a Job object.
+ */
+ public Job runQuery() {
+ return runQuery("", null);
+ }
+
+ /**
+ * Start a job that fetches all the events of this data model object.
+ *
+ * @param args arguments specifying behavior of the job.
+ * @return a Job object.
+ */
+ public Job runQuery(JobArgs args) {
+ return runQuery("", args);
+ }
+
+ /**
+ * Start a job that applies querySuffix to all the events in this data model object.
+ *
+ * @param querySuffix a search query, starting with a '|' that will be appended to the command to fetch
+ * the contents of this data model object (e.g., "| head 3").
+ * @return a Job object.
+ */
+ public Job runQuery(String querySuffix) {
+ return runQuery(querySuffix, null);
+ }
+
+ /**
+ * Start a job that applies querySuffix to all the events in this data model object.
+ *
+ * @param querySuffix a search query, starting with a '|' that will be appended to the command to fetch
+ * the contents of this data model object (e.g., "| head 3").
+ * @param args arguments to control the job.
+ * @return a Job object.
+ */
+ public Job runQuery(String querySuffix, JobArgs args) {
+ return getDataModel().getService().search(getQuery() + querySuffix, args);
+ }
+
+ /**
+ * Produce a data model object from a JSON dictionary specifying it plus a data model that contains it.
+
+ * @param dataModel a DataModel instance that contains this data model object.
+ * @param object a JsonElement (as produced by Gson) specifying this data model object (usually one of
+ * the entries in the array of objects in the JSON description of the data model).
+ * @return a DataModelObject instance.
+ */
+ static DataModelObject parse(DataModel dataModel, JsonElement object) {
+ String name = null;
+ String displayName = null;
+ String comment = null;
+ String[] lineage = new String[0];
+ String parentName = null;
+ Map fields = new HashMap();
+ Collection children = new ArrayList();
+ Collection constraints = new ArrayList();
+ Map calculations = new HashMap();
+
+ // Fields specific to objects inheriting directly from BaseSearch.
+ String baseSearch = null;
+ // Fields specific to objects inheriting directly from BaseTransaction
+ String transactionMaxPause = null;
+ String transactionMaxTimeSpan = null;
+ Collection groupByFields = new ArrayList();
+ Collection objectsToGroup = new ArrayList();
+
+ for (Entry entry : object.getAsJsonObject().entrySet()) {
+ if (entry.getKey().equals("objectName")) {
+ name = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("displayName")) {
+ displayName = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("lineage")) {
+ lineage = entry.getValue().getAsString().split("\\.");
+ } else if (entry.getKey().equals("parentName")) {
+ parentName = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("fields")) {
+ JsonArray fieldsJson = entry.getValue().getAsJsonArray();
+ fields.clear();
+
+ for (JsonElement fieldJson : fieldsJson) {
+ DataModelField field = DataModelField.parse(fieldJson);
+ fields.put(field.getName(), field);
+ }
+ } else if (entry.getKey().equals("constraints")) {
+ JsonArray constraintsJson = entry.getValue().getAsJsonArray();
+
+ for (JsonElement constraintJson : constraintsJson) {
+ DataModelConstraint constraint = DataModelConstraint.parse(constraintJson);
+ constraints.add(constraint);
+ }
+ } else if (entry.getKey().equals("calculations")) {
+ calculations.clear();
+ for (JsonElement cjson : entry.getValue().getAsJsonArray()) {
+ DataModelCalculation c = DataModelCalculation.parse(cjson);
+ String cid = c.getCalculationID();
+ calculations.put(cid, c);
+ }
+ } else if (entry.getKey().equals("baseSearch")) {
+ baseSearch = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("transactionMaxPause")) {
+ transactionMaxPause = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("transactionMaxTimeSpan")) {
+ transactionMaxTimeSpan = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("groupByFields")) {
+ for (JsonElement e : entry.getValue().getAsJsonArray()) {
+ groupByFields.add(e.getAsString());
+ }
+ } else if (entry.getKey().equals("objectsToGroup")) {
+ for (JsonElement e : entry.getValue().getAsJsonArray()) {
+ objectsToGroup.add(e.getAsString());
+ }
+ }
+ }
+
+ DataModelObject dmo;
+ // Create the right subclass of DataModelObject.
+ if (baseSearch != null) {
+ dmo = new DataModelSearch(dataModel);
+ } else if (transactionMaxPause != null) {
+ dmo = new DataModelTransaction(dataModel);
+ } else {
+ dmo = new DataModelObject(dataModel);
+ }
+
+ // Set the fields common to all data model objects
+ dmo.name = name;
+ dmo.displayName = displayName;
+ dmo.lineage = lineage;
+ dmo.parentName = parentName;
+ dmo.autoextractedFields = fields;
+ dmo.constraints = constraints;
+ dmo.calculations = calculations;
+
+ // Set the fields of particular types
+ if (baseSearch != null) {
+ ((DataModelSearch)dmo).baseSearch = baseSearch;
+ } else if (transactionMaxPause != null) {
+ ((DataModelTransaction)dmo).groupByFields = groupByFields;
+ ((DataModelTransaction)dmo).objectsToGroup = objectsToGroup;
+ ((DataModelTransaction)dmo).maxPause = transactionMaxPause;
+ ((DataModelTransaction)dmo).maxSpan = transactionMaxTimeSpan;
+ } else {
+ // Has no additional fields
+ }
+
+ return dmo;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelSearch.java b/splunk/src/main/java/com/splunk/DataModelSearch.java
new file mode 100644
index 00000000..87f2e37f
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelSearch.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 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;
+
+/**
+ * DataModelSearch represents a data model object that directly wraps a Splunk search query.
+ *
+ * It appears only as a direct subobject of the BaseSearch built-in type. All its children
+ * appear as normal DataModelObject instances. DataModelSearch objects have one additional
+ * getter, getBaseSearch, which returns the underlying search which this object
+ * wraps.
+ */
+public class DataModelSearch extends DataModelObject {
+ protected String baseSearch;
+
+ DataModelSearch(DataModel model) {
+ super(model);
+ }
+
+ /**
+ * @return the search query wrapped by this data model object.
+ */
+ public String getBaseSearch() {
+ return baseSearch;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DataModelTransaction.java b/splunk/src/main/java/com/splunk/DataModelTransaction.java
new file mode 100644
index 00000000..a95d07a0
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DataModelTransaction.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2014 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;
+
+/**
+ * Represents a datamodel object that inherits directly from BaseTransaction,
+ * that is, an object that wraps a Splunk transaction. All children of this
+ * object will appears as standard DataModelObject instances.
+ */
+public class DataModelTransaction extends DataModelObject {
+ protected Collection groupByFields;
+ protected Collection objectsToGroup;
+ protected String maxSpan;
+ protected String maxPause;
+
+ DataModelTransaction(DataModel dataModel) {
+ super(dataModel);
+ }
+
+ /**
+ * @return the fields that will be used to group events into transactions.
+ *
+ * Contiguous events with identical values of the fields named in this collection
+ * will be grouped into transactions.
+ */
+ public Collection getGroupByFields() { return this.groupByFields; }
+
+ /**
+ * @return the names of the data model objects that should be unioned and split into transactions.
+ */
+ public Collection getObjectsToGroup() { return this.objectsToGroup; }
+
+ /**
+ * maxSpan is the maximum amount of time (in a Splunk defined format, such as "1m"
+ * for one minute or "20s" for twenty seconds) that a single transaction can span.
+ * When a transaction reaches this size, it is automatically ended and a new transaction
+ * begun.
+ *
+ * @return The maximum time that a transaction can span.
+ */
+ public String getMaxSpan() { return this.maxSpan; }
+
+ /**
+ * maxPause is the maximum amount of time between two events in a transaction, specified as a string
+ * such as "1m" for one minute or "20s" for twenty seconds. When a transaction
+ * has a gap of at least maxPause since its last even, it is ended and a new transaction begun.
+ *
+ * @return the maximum pause between events in a transaction.
+ */
+ public String getMaxPause() { return this.maxPause; }
+}
diff --git a/splunk/src/main/java/com/splunk/DeploymentClient.java b/splunk/src/main/java/com/splunk/DeploymentClient.java
new file mode 100644
index 00000000..b67e3a2b
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DeploymentClient.java
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+/**
+ * The {@code DeploymentClient} class represents a Splunk deployment client,
+ * providing access to deployment client configuration and status.
+ */
+public class DeploymentClient extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ DeploymentClient(Service service) {
+ super(service, "deployment/client");
+ }
+
+ /**
+ * Displays the action path.
+ *
+ * @param action The requested action.
+ * @return The action path.
+ */
+ @Override protected String actionPath(String action) {
+ if (action.equals("edit"))
+ return path + "/deployment-client";
+ return super.actionPath(action);
+ }
+
+ /** Not supported for this endpoint. */
+ @Override public void disable() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** Not supported for this endpoint. */
+ @Override public void enable() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the list of server classes.
+ *
+ * @return The list of server classes, or {@code null} if not specified.
+ */
+ public String [] getServerClasses() {
+ return getStringArray("serverClasses", null);
+ }
+
+ /**
+ * Returns the target URI of the deployment server for this deployment
+ * client.
+ *
+ * @return The target URI of the deployment server in the
+ * format "server:port", or {@code null} if not specified.
+ */
+ public String getTargetUri() {
+ return getString("targetUri", null);
+ }
+
+ /**
+ * Reloads the deployment client from the configuration file.
+ */
+ public void reload() {
+ service.get(path + "/deployment-client/Reload");
+ invalidate();
+ }
+
+ /**
+ * Sets whether to enable or disable the deployment client.
+ *
+ * Note: Using this method requires you to restart Splunk before this
+ * setting takes effect. To avoid restarting Splunk, use the
+ * {@code Entity.disable} and {@code Entity.enable} methods instead, which
+ * take effect immediately.
+ * @see Entity#disable
+ * @see Entity#enable
+ *
+ * @param disabled {@code true} to disable the deployment client,
+ * {@code false} to enable it.
+ */
+ public void setDisabled(boolean disabled) {
+ setCacheValue("disabled", disabled);
+ }
+
+ /**
+ * Sets the deployment server's target URI for this deployment client. The
+ * form of this URI is "deployment_server_uir:port".
+ *
+ * @param targetUri The target URI of the deployment server.
+ */
+ public void setTargetUri(String targetUri) {
+ setCacheValue("targetUri", targetUri);
+ }
+}
+
diff --git a/splunk/src/main/java/com/splunk/DeploymentServer.java b/splunk/src/main/java/com/splunk/DeploymentServer.java
new file mode 100644
index 00000000..df1bb20b
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DeploymentServer.java
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+/**
+ * The {@code DeploymentServer} class represents a Splunk deployment server,
+ * and provides access to the configurations of all deployment servers.
+ */
+public class DeploymentServer extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The deployment server endpoint.
+ */
+ DeploymentServer(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns inclusive criteria for determining deployment client access to
+ * this deployment server.
+ *
+ * @param index The index of the whitelist entry to return.
+ * @return A list of included client addresses, or {@code null} if not
+ * specified.
+ */
+ public String getWhitelistByIndex(int index) {
+ return getString(String.format("whitelist.%d", index), null);
+ }
+
+ /**
+ * Sets whether the deployment server is enabled or disabled.
+ *
+ * Note: Using this method requires you to restart Splunk before this
+ * setting takes effect. To avoid restarting Splunk, use the
+ * {@code Entity.disable} and {@code Entity.enable} methods instead, which
+ * take effect immediately.
+ * @see Entity#disable
+ * @see Entity#enable
+ *
+ * @param disabled {@code true} to disable the deployment client,
+ * {@code false} to enable it.
+ */
+ public void setDisabled(boolean disabled) {
+ setCacheValue("disabled", disabled);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/DeploymentServerClass.java b/splunk/src/main/java/com/splunk/DeploymentServerClass.java
new file mode 100644
index 00000000..e2c3c31d
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DeploymentServerClass.java
@@ -0,0 +1,224 @@
+/*
+ * 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;
+
+/**
+ * The {@code DeploymentServerClass} class represents a Splunk deployment server
+ * class, providing access to the configuration of a server class.
+ */
+public class DeploymentServerClass extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The deployment server class endpoint.
+ */
+ DeploymentServerClass(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns a list of the hosts that are excluded from this server class.
+ *
+ * @return A comma-separated list of excluded hosts, or {@code null} if not
+ * specified.
+ */
+ public String getBlacklist() {
+ return getString("blacklist", null);
+ }
+
+ /**
+ * Returns a list of excluded client addresses, by index.
+ *
+ * @param index The index of the blacklist entry to return. The only valid
+ * index is 0.
+ * @return A list of excluded client addresses, or {@code null} if not
+ * specified.
+ */
+ public String getBlacklistByIndex(int index) {
+ return getString(String.format("blacklist.%d", index), null);
+ }
+
+ /**
+ * Indicates whether look-ups halt on the first server match or continue
+ * to match against multiple servers. Matching is done in the order that
+ * server classes are defined.
+ *
+ * @return {@code true} if configuration look-ups continue matching server
+ * classes, beyond the first match. {@code false} if only the first match
+ * is used.
+ */
+ public boolean getContinueMatching() {
+ return getBoolean("continueMatching", false);
+ }
+
+ /**
+ * Returns the URL template string, which specifies the endpoint from which
+ * content can be downloaded by a deployment client.
+ *
+ * @return The URL template string for deployment client downloads, or
+ * {@code null} if not specified.
+ */
+ public String getEndpoint() {
+ return getString("endpoint", null);
+ }
+
+ /**
+ * Returns the filter type that is applied first. If {@code filterType} is
+ * "whitelist", all whitelist filters are applied first, followed by
+ * blacklist filters. If {@code filterType} is "blacklist", all blacklist
+ * filters are applied first, followed by whitelist filters.
+ *
+ * @return The filter type.
+ */
+ public String getFilterType() {
+ return getString("filterType");
+ }
+
+ /**
+ * Returns the location on the deployment server to store the content
+ * that is to be deployed for this server class.
+ *
+ * Note: The path may contain macro expansions or substitutions.
+ *
+ * @return The file path for content storage on the deployment server.
+ */
+ public String getRepositoryLocation() {
+ return getString("repositoryLocation");
+ }
+
+ /**
+ * Returns the location on the deployment client where the content to be
+ * deployed for this server class should be installed.
+ *
+ * Note: The path may contain macro expansions or substitutions.
+ *
+ * @return The file path for content storage on the deployment client.
+ */
+ public String getTargetRepositoryLocation() {
+ return getString("targetRepositoryLocation", null);
+ }
+
+ /**
+ * Returns the location of the working folder used by the deployment server.
+ *
+ * Note: The path may contain macro expansions or substitutions.
+ *
+ * @return The path to the deployment server's working folder, or
+ * {@code null} if not specified.
+ */
+ public String getTmpFolder() {
+ return getString("tmpFolder", null);
+ }
+
+ /**
+ * Returns a list of hosts included for this server class.
+ * @return A comma-separated list of included hosts, or {@code null} if not
+ * specified.
+ */
+ public String getWhitelist() {
+ return getString("whitelist", null);
+ }
+
+ /**
+ * Returns a list of included client addresses, by index.
+ *
+ * @param index The index of the whitelist entry to return. Valid indexes
+ * are 0 and 1.
+ * @return A list of included client addresses, or {@code null} if not
+ * specified.
+ */
+ public String getWhitelistByIndex(int index) {
+ return getString(String.format("whitelist.%d", index), null);
+ }
+
+ /**
+ * Sets a specific blacklist entry.
+ *
+ * @param index The index of the blacklist entry to set.
+ * @param blacklist The blacklist entry.
+ */
+ public void setBlacklistByIndex(int index, String blacklist) {
+ setCacheValue(String.format("blacklist.%d", index), blacklist);
+ }
+
+ /**
+ * Sets how this deployment server class controls its configurations
+ * across classes and server-specific settings. If set to {@code true},
+ * configuration look-ups continue matching server classes after the first
+ * match. If set to {@code false}, only the first match is used. Matching
+ * is done in the order that server classes are defined.
+ *
+ * @param matching {@code true} to continue matching, {@code false} to use
+ * the first match.
+ */
+ public void setContinueMatching(boolean matching) {
+ setCacheValue("continueMatching", matching);
+ }
+
+ /**
+ * Sets a URL template string that specifies the endpoint from which
+ * content can be downloaded by a deployment client. The deployment client
+ * knows how to substitute the values of the variables in the URL. Any
+ * custom URL can be provided here as long as it uses the specified
+ * variables.
+ *
+ * You don't have to set this URL template string unless you have a very
+ * specific need--for example, you need to acquire deployment application
+ * files from a third-party httpd for extremely large environments.
+ *
+ * @param endPoint The endpoint URL.
+ */
+ public void setEndPoint(String endPoint) {
+ setCacheValue("endpoint", endPoint);
+ }
+
+ /**
+ * Sets the order to apply filters:
+ *
"whitelist" applies the whitelist filters first, followed by
+ * blacklist filters.
+ *
"blacklist" applies the blacklist filters first, followed by
+ * whitelist filters.
+ *
+ * @param filterType The filter type to apply first.
+ */
+ public void setFilterType(String filterType) {
+ setCacheValue("filterType", filterType);
+ }
+
+ /**
+ * Sets the location on the deployment server to store the content that is
+ * to be deployed for this server class.
+ *
+ * @param location The location (path) for storing content.
+ */
+ public void setRepositoryLocation(String location) {
+ setCacheValue("repositoryLocation", location);
+
+ }
+
+ /**
+ * Sets a specific whitelist entry.
+ *
+ * @param index The index of the whitelist entry to set.
+ * @param whitelist The whitelist entry.
+ */
+ public void setWhitelistByIndex(int index, String whitelist) {
+ setCacheValue(String.format("whitelist.%d", index), whitelist);
+ }
+}
diff --git a/splunk/com/splunk/DeploymentTenant.java b/splunk/src/main/java/com/splunk/DeploymentTenant.java
similarity index 50%
rename from splunk/com/splunk/DeploymentTenant.java
rename to splunk/src/main/java/com/splunk/DeploymentTenant.java
index e609f51f..67edff79 100644
--- a/splunk/com/splunk/DeploymentTenant.java
+++ b/splunk/src/main/java/com/splunk/DeploymentTenant.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,15 @@
package com.splunk;
/**
- * Representation of a Splunk deployment tenant.
+ * The {@code DeploymentTenant} class represents a Splunk deployment tenant, and
+ * provides access to the multi-tenants configuration for this Splunk instance.
*/
public class DeploymentTenant extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The deployment tenant endpoint.
*/
DeploymentTenant(Service service, String path) {
@@ -32,26 +33,32 @@ public class DeploymentTenant extends Entity {
}
/**
- * Returns whether or not this deployment server should review its
- * configuration, in a multi-tenant configuration, and inform the deployment
- * client if something is new or updated.
+ * Returns inclusive criteria for determining deployment client access to
+ * this deployment server.
*
- * @return Whether this deployment server notifies the deployment client for
- * new or changed configurations.
+ * @param index The whitelist index. The only valid index is 0.
+ * @return Criteria for determining deployment client access to this
+ * deployment server.
*/
- public boolean getCheckNew() {
- return getBoolean("check-new", false);
+ public String getWhitelistByIndex(int index) {
+ return getString(String.format("whitelist.%d", index), null);
}
/**
- * Returns inclusive criteria for determining deployment client access to
- * this deployment server.
+ * Sets whether the deployment tenant is enabled or disabled.
+ *
+ * Note: Using this method requires you to restart Splunk before this
+ * setting takes effect. To avoid restarting Splunk, use the
+ * {@code Entity.disable} and {@code Entity.enable} methods instead, which
+ * take effect immediately.
+ * @see Entity#disable
+ * @see Entity#enable
*
- * @return Criteria for determining deployment client access to this
- * deployment server.
+ * @param disabled {@code true} to disabled to deployment client,
+ * {@code false} to enable.
*/
- public String getWhiteList0() {
- return getString("whitelist.0");
+ public void setDisabled(boolean disabled) {
+ setCacheValue("disabled", disabled);
}
}
diff --git a/splunk/src/main/java/com/splunk/DistributedConfiguration.java b/splunk/src/main/java/com/splunk/DistributedConfiguration.java
new file mode 100644
index 00000000..4105d1b4
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DistributedConfiguration.java
@@ -0,0 +1,321 @@
+/*
+ * 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;
+
+/**
+ * The {@code DistributedConfiguration} class represents a Splunk distributed
+ * search configuration, providing access to Splunk's distributed search
+ * options.
+ */
+public class DistributedConfiguration extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ DistributedConfiguration(Service service) {
+ super(service, "search/distributed/config");
+ }
+
+ /**
+ * Returns the action path.
+ *
+ * @param action The requested action.
+ * @return The action path.
+ */
+ @Override protected String actionPath(String action) {
+ if (action.equals("edit"))
+ return path + "/distributedSearch";
+ return super.actionPath(action);
+ }
+
+ /**
+ * Disable distributed search on this Splunk instance.
+ *
+ * Requires restarting Splunk before it takes effect.
+ */
+ @Override
+ public void disable() {
+ Args args = new Args();
+ args.put("disabled", "1");
+ update(args);
+ }
+
+ /**
+ * Enable distributed search on this Splunk instance.
+ *
+ * Requires restarting Splunk before it takes effect.
+ */
+ @Override
+ public void enable() {
+ Args args = new Args();
+ args.put("disabled", "0");
+ update(args);
+ }
+
+ /**
+ * Returns a list of server names that are excluded from being peers.
+ *
+ * @return A comma-separated list of excluded servers by name, or
+ * {@code null} if not available.
+ */
+ public String getBlacklistNames() {
+ return getString("blacklistNames", null);
+ }
+
+ /**
+ * Returns a list of server URLs that are excluded from being peers.
+ *
+ * @return A comma-separated list of excluded servers by URL in the
+ * format "x.x.x.x:port", or {@code null} if not available.
+ */
+ public String getBlacklistUrls() {
+ return getString("blacklistURLs", null);
+ }
+
+ /**
+ * Returns the time-out period for connecting to search peers.
+ *
+ * @return The connection time-out period, in seconds, or -1 if not
+ * specified.
+ */
+ public int getConnectionTimeout() {
+ return getInteger("connectionTimeout", -1);
+ }
+
+ /**
+ * Returns the frequency at which servers that have timed out are rechecked.
+ * If {@code removeTimedOutServers} is false, this setting has no effect.
+ *
+ * @return The frequency, in seconds, to recheck timed-out servers. If 0,
+ * servers are not rechecked. The default is 60 seconds.
+ */
+ public int getCheckTimedOutServersFrequency() {
+ return getInteger("checkTimedOutServersFrequency", 60);
+ }
+
+ /**
+ * Returns the time-out period for trying to read and receive data from a
+ * search peer.
+ *
+ * @return The receive time-out period, in seconds, or -1 if not specified.
+ */
+ public int getReceiveTimeout() {
+ return getInteger("receiveTimeout", -1);
+ }
+
+ /**
+ * Indicates whether timed-out servers are removed from the distributed
+ * configuration.
+ *
+ * @return {@code true} if timed-out servers are removed from the
+ * distributed configuration, {@code false} if not.
+ */
+ public boolean getRemovedTimedOutServers() {
+ return getBoolean("removedTimedOutServers", false);
+ }
+
+ /**
+ * Returns the time-out period for trying to write or send data to a search
+ * peer.
+ *
+ * @return The send time-out period, in seconds, or -1 if not specified.
+ */
+ public int getSendTimeout() {
+ return getInteger("sendTimeout", -1);
+ }
+
+ /**
+ * Returns a list of peer servers.
+ *
+ * @return The comma-separated list of peer servers, or {@code null} if not
+ * available.
+ */
+ public String getServers() {
+ return getString("servers", null);
+ }
+
+ /**
+ * Indicates whether this server uses bundle replication to share
+ * search-time configuration with search peers.
+ *
+ * Note: If set to {@code false}, the search head assumes that the
+ * search peers can access the correct bundles using an NFS share.
+ *
+ * @return {@code true} if this server uses bundle replication,
+ * {@code false} if not.
+ */
+ public boolean getShareBundles() {
+ return getBoolean("shareBundles", true);
+ }
+
+ /**
+ * Returns the time-out period for gathering a search peer's basic information.
+ *
+ * @return The time-out period, in seconds.
+ * @see ServiceInfo
+ */
+ public int getStatusTimeout() {
+ return getInteger("statusTimeout", 10);
+ }
+
+ /**
+ * Indicates whether distributed search is enabled.
+ *
+ * @return {@code true} if distributed search is enabled, {@code false} if
+ * disabled.
+ */
+ public boolean isDistSearchEnabled() {
+ return getBoolean("dist_search_enabled", true);
+ }
+
+ /**
+ * Sets the blacklist server names that are excluded from being peers.
+ *
+ * @param names A comma-separated list of server names.
+ */
+ public void setBlacklistNames(String names) {
+ setCacheValue("blacklistNames", names);
+ }
+
+ /**
+ * Sets the blacklist server names or URIs that are excluded from being
+ * peers. The format for a URI is "x.x.x.x:port".
+ *
+ * @param names A comma-separated list of server names or URIs.
+ */
+ public void setBlacklistURLs(String names) {
+ setCacheValue("blacklistURLs", names);
+ }
+
+ /**
+ * Sets the server recheck frequency.
+ *
+ * Note: This attribute is only relevant when
+ * {@code removeTimedOutServers} is set to {@code true}--otherwise, this
+ * attribute is ignored.
+ * @see #getRemovedTimedOutServers
+ *
+ * @param frequency The server recheck frequency, in seconds. If set to 0, a
+ * recheck does not occur.
+ */
+ public void setCheckTimedOutServersFrequency(int frequency) {
+ setCacheValue("checkTimedOutServersFrequency", frequency);
+ }
+
+ /**
+ * Sets the time-out period for establishing a search peer connection.
+ *
+ * @param seconds The connection time-out period, in seconds.
+ */
+ public void setConnectionTimeout(int seconds) {
+ setCacheValue("connectionTimeout", seconds);
+ }
+
+ /**
+ * Sets whether the distributed configuration is enabled or disabled.
+ *
+ * Note: Using this method requires you to restart Splunk before this
+ * setting takes effect. To avoid restarting Splunk, use the
+ * {@code Entity.disable} and {@code Entity.enable} methods instead, which
+ * take effect immediately.
+ * @see Entity#disable
+ * @see Entity#enable
+ *
+ * @param disabled {@code true} to disabled to deployment client,
+ * {@code false} to enable.
+ */
+ public void setDisabled(boolean disabled) {
+ setCacheValue("disabled", disabled);
+ }
+
+ /**
+ * Sets the time-out period for reading and receiving data from a search
+ * peer.
+ *
+ * @param seconds The receive time-out period, in seconds.
+ */
+ public void setReceiveTimeout(int seconds) {
+ setCacheValue("receiveTimeout", seconds);
+ }
+
+ /**
+ * Sets whether to remove a server connection that cannot be made within the
+ * time-out period specified by {@code connectionTimeout},
+ * {@code sendTimeout}, or {@code receiveTimeout}.
+ * If {@code false}, every call to that server attempts to connect, which
+ * might result in a slow user interface.
+ * @see #setConnectionTimeout
+ * @see #setSendTimeout
+ * @see #setReceiveTimeout
+ *
+ * @param removeTimedOutServers {@code true} to remove timed-out server
+ * connections, {@code false} to attempt every call to the server.
+ */
+ public void setRemoveTimedOutServers(boolean removeTimedOutServers) {
+ setCacheValue("removedTimedOutServers", removeTimedOutServers);
+ }
+
+ /**
+ * Sets the time-out period for writing and sending data to a search peer.
+ *
+ * @param seconds The send time-out period, in seconds.
+ */
+ public void setSendTimeout(int seconds) {
+ setCacheValue("sendTimeout", seconds);
+ }
+
+ /**
+ * Sets the initial peer server list. You don't need to set servers here
+ * if you are operating completely in {@code autoAddServers} mode
+ * (discovered servers are automatically added).
+ *
+ * @param servers A comma-separated list of peer servers.
+ */
+ public void setServers(String servers) {
+ setCacheValue("servers", servers);
+ }
+
+ /**
+ * Sets whether this server uses bundle replication to share search-time
+ * configuration with search peers.
+ *
+ * If set to {@code false}, the search head assumes that the search peers
+ * can access the correct bundles using an NFS share and have correctly
+ * configured the options for mounted_bundles and bundles_location in the
+ * distsearch.conf file.
+ *
+ * @param shareBundles {@code true} to share search-time configuration
+ * with peers, {@code false} if not.
+ */
+ public void setShareBundles(boolean shareBundles) {
+ setCacheValue("shareBundles", shareBundles);
+ }
+
+ /**
+ * Sets the time-out period for connecting to a search peer for getting its
+ * basic information.
+ *
+ * @param seconds The connection time-out period, in seconds.
+ * @see ServiceInfo
+ */
+ public void setStatusTimeout(int seconds) {
+ setCacheValue("statusTimeout", seconds);
+ }
+
+}
diff --git a/splunk/src/main/java/com/splunk/DistributedPeer.java b/splunk/src/main/java/com/splunk/DistributedPeer.java
new file mode 100644
index 00000000..2a42a75f
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/DistributedPeer.java
@@ -0,0 +1,149 @@
+/*
+ * 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;
+
+/**
+ * The {@code DistributedPeer} class represents a Splunk distributed peer,
+ * providing distributed peer server management.
+ */
+public class DistributedPeer extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The deployment server endpoint.
+ */
+ DistributedPeer(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns this peer's build number.
+ *
+ * @return The build number.
+ */
+ public String getBuild() {
+ return getString("build");
+ }
+
+ /**
+ * Returns a list of bundle versions.
+ *
+ * @return The bundle versions, or {@code null} if not specified.
+ */
+ public String[] getBundleVersions() {
+ return getStringArray("bundle_versions", null);
+ }
+
+ /**
+ * Returns this peer's GUID.
+ *
+ * @return The GUID, or {@code null} if not specified.
+ */
+ public String getGuid() {
+ return getString("guid", null);
+ }
+
+ /**
+ * Returns this peer's license signature.
+ *
+ * @return The license signature, or {@code null} if not specified.
+ */
+ public String getLicenseSignature() {
+ return getString("licenseSignature", null);
+ }
+
+ /**
+ * Returns this peer's name.
+ *
+ * @return The name, or {@code null} if not specified.
+ */
+ public String getPeerName() {
+ return getString("peerName", null);
+ }
+
+ /**
+ * Returns this peer's type.
+ *
+ * @return The type, or {@code null} if not specified.
+ */
+ public String getPeerType() {
+ return getString("peerType", null);
+ }
+
+ /**
+ * Returns this peer's replication status.
+ *
+ * @return The replication status, or {@code null} if not specified.
+ */
+ public String getReplicationStatus() {
+ return getString("replicationStatus", null);
+ }
+
+ /**
+ * Return this peer's overall status.
+ *
+ * @return The overall status, or {@code null} if not specified.
+ */
+ public String getStatus() {
+ return getString("status", null);
+ }
+
+ /**
+ * Returns this peer's version.
+ *
+ * @return The version, or {@code null} if not specified.
+ */
+ public String getVersion() {
+ return getString("version", null);
+ }
+
+ /**
+ * Indicates whether this peer is using HTTPS.
+ *
+ * @return {@code true} if this peer is using HTTPS, {@code false} if not.
+ */
+ public boolean isHttps() {
+ return getBoolean("is_https", true);
+ }
+
+ /**
+ * Sets the remote password.
+ *
+ * Note: The username and password must be set at the same time.
+ * @see #setRemoteUsername
+ *
+ * @param password The remote password.
+ */
+ public void setRemotePassword(String password) {
+ setCacheValue("remotePassword", password);
+ }
+
+ /**
+ * Sets the remote username.
+ *
+ * Note: The username and password must be set at the same time.
+ * @see #setRemotePassword
+ *
+ * @param username The remote username.
+ */
+ public void setRemoteUsername(String username) {
+ setCacheValue("remoteUsername", username);
+ }
+}
+
diff --git a/splunk/com/splunk/Entity.java b/splunk/src/main/java/com/splunk/Entity.java
similarity index 59%
rename from splunk/com/splunk/Entity.java
rename to splunk/src/main/java/com/splunk/Entity.java
index d50a21be..a4856e2a 100644
--- a/splunk/com/splunk/Entity.java
+++ b/splunk/src/main/java/com/splunk/Entity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -16,31 +16,29 @@
package com.splunk;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
- * Base class for all Splunk entity resources.
+ * The {@code Entity} class represents a Splunk entity.
*/
public class Entity extends Resource implements Map {
- private Record content;
+ protected Record content;
+ protected HashMap toUpdate = new LinkedHashMap();
/**
* Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The entity's endpoint.
*/
- Entity(Service service, String path) {
+ public Entity(Service service, String path) {
super(service, path);
}
/**
- * Returns the path corresponding to the requested action.
+ * Returns the path that corresponds to the requested action.
*
- * @param action Action requested.
+ * @param action The requested action.
* @return The return path.
*/
protected String actionPath(String action) {
@@ -50,10 +48,10 @@ protected String actionPath(String action) {
return path;
if (action.equals("enable"))
return path + "/enable";
- if (action.equals("reload"))
- return path + "/_reload";
if (action.equals("remove"))
return path;
+ if (action.equals("acl"))
+ return path + "/acl";
throw new IllegalArgumentException("Invalid action: " + action);
}
@@ -73,8 +71,8 @@ public boolean containsValue(Object value) {
}
/**
- * Disabled the entity named by this endpoint. Available on almost every
- * endpoint.
+ * Disables the entity that is named by this endpoint. This method is
+ * available on almost every endpoint.
*/
public void disable() {
service.post(actionPath("disable"));
@@ -82,8 +80,8 @@ public void disable() {
}
/**
- * Enables the entity named by this endpoint. Available on almost every
- * endpoint.
+ * Enables the entity that is named by this endpoint. This method is
+ * available on almost every endpoint.
*/
public void enable() {
service.post(actionPath("enable"));
@@ -97,58 +95,67 @@ public Set> entrySet() {
/** {@inheritDoc} */
public Object get(Object key) {
+ if (toUpdate.containsKey(key)) return toUpdate.get(key);
return getContent().get(key);
}
/**
- * Returns the boolean value associated with the specified key. Values
- * values can be converted from the set 0, 1, true, false.
+ * Returns the Boolean value associated with the specified key. Values
+ * can be converted from: 0, 1, true, false.
*
* @param key The key to look up.
- * @return The boolean value associated with the specified key.
+ * @return The Boolean value associated with the specified key.
*/
boolean getBoolean(String key) {
+ if (toUpdate.containsKey(key))
+ return Value.toBoolean(toUpdate.get(key).toString());
return getContent().getBoolean(key);
}
/**
- * Returns the boolean value associated with the specified key, or the
+ * Returns the Boolean value associated with the specified key, or the
* default value if the key does not exist. Boolean values can be converted
- * from the set 0, 1, true, false.
+ * from: 0, 1, true, false.
*
* @param key The key to look up.
* @param defaultValue The default value.
- * @return The boolean value associated with the specified key.
+ * @return The Boolean value associated with the specified key.
*/
boolean getBoolean(String key, boolean defaultValue) {
+ if (toUpdate.containsKey(key))
+ return Value.toBoolean(toUpdate.get(key).toString());
return getContent().getBoolean(key, defaultValue);
}
/**
* Returns the long value associated with the specified key. Long values
- * can be converted from the set number, numberMB, numberGB.
+ * can be converted from: number, numberMB, numberGB.
*
* @param key The key to look up.
* @return The long value associated with the specified key.
*/
long getByteCount(String key) {
+ if (toUpdate.containsKey(key))
+ return Value.toByteCount(toUpdate.get(key).toString());
return getContent().getByteCount(key);
}
/**
* Returns the long value associated with the specified key, or the default
- * value if the key does not exist. Long values can be converted from the
- * set number, numberMB, numberGB.
+ * value if the key does not exist. Long values can be converted from:
+ * number, numberMB, numberGB.
*
* @param key The key to look up.
* @param defaultValue The default value.
* @return The long value associated with the specified key.
*/
long getByteCount(String key, long defaultValue) {
+ if (toUpdate.containsKey(key))
+ return Value.toByteCount(toUpdate.get(key).toString());
return getContent().getByteCount(key, defaultValue);
}
- private Record getContent() {
+ protected Record getContent() {
return validate().content;
}
@@ -160,12 +167,18 @@ private Record getContent() {
* @return The date value associated with the specified key.
*/
Date getDate(String key) {
- return getContent().getDate(key);
+ if (toUpdate.containsKey(key))
+ return Value.toDate(toUpdate.get(key).toString());
+ if (getContent().containsKey(key)) {
+ return getContent().getDate(key);
+ } else {
+ return null;
+ }
}
/**
* Returns a date value associated with the specified key, or the default
- * value if the key does not exist. ate values can be converted from
+ * value if the key does not exist. Date values can be converted from
* standard UTC time formats.
*
* @param key The key to look up.
@@ -173,33 +186,11 @@ Date getDate(String key) {
* @return The date value associated with the specified key.
*/
Date getDate(String key, Date defaultValue) {
+ if (toUpdate.containsKey(key))
+ return Value.toDate(toUpdate.get(key).toString());
return getContent().getDate(key, defaultValue);
}
- /**
- * Returns a date value associated with the specified key. Date values can
- * be converted from epoch time formats.
- *
- * @param key The key to look up.
- * @return The date value associated with the specified. key.
- */
- Date getDateFromEpoch(String key) {
- return getContent().getDateFromEpoch(key);
- }
-
- /**
- * Returns a date value associated with the specified key, or the default
- * value if the key does not exist. Date values can be converted from epoch
- * time formats.
- *
- * @param key The key to look up.
- * @param defaultValue The default value.
- * @return The date value associated with the specified. key.
- */
- Date getDateFromEpoch(String key, Date defaultValue) {
- return getContent().getDateFromEpoch(key, defaultValue);
- }
-
/**
* Returns the floating point value associated with the specified key.
*
@@ -207,6 +198,8 @@ Date getDateFromEpoch(String key, Date defaultValue) {
* @return The floating point value associated with the specified key.
*/
float getFloat(String key) {
+ if (toUpdate.containsKey(key))
+ return Value.toFloat(toUpdate.get(key).toString());
return getContent().getFloat(key);
}
@@ -217,6 +210,8 @@ float getFloat(String key) {
* @return The integer point value associated with the specified key.
*/
int getInteger(String key) {
+ if (toUpdate.containsKey(key))
+ return Value.toInteger(toUpdate.get(key).toString());
return getContent().getInteger(key);
}
@@ -228,6 +223,8 @@ int getInteger(String key) {
* @return The integer value associated with the specified key.
*/
int getInteger(String key, int defaultValue) {
+ if (toUpdate.containsKey(key))
+ return Value.toInteger(toUpdate.get(key).toString());
return getContent().getInteger(key, defaultValue);
}
@@ -238,6 +235,8 @@ int getInteger(String key, int defaultValue) {
* @return The long value associated with the specified key.
*/
long getLong(String key) {
+ if (toUpdate.containsKey(key))
+ return Value.toLong(toUpdate.get(key).toString());
return getContent().getLong(key);
}
@@ -249,17 +248,21 @@ long getLong(String key) {
* @return The long value associated with the specified key.
*/
long getLong(String key, int defaultValue) {
+ if (toUpdate.containsKey(key))
+ return Value.toLong(toUpdate.get(key).toString());
return getContent().getLong(key, defaultValue);
}
/**
- * Returns the meta data (eai:acl) of this entity, or null if none exist.
+ * Returns the metadata (eai:acl) of this entity. This data includes
+ * permissions for accessing the resource, and values that indicate
+ * which resource fields are wildcards, required, and optional.
*
- * @return the meta data of this entity.
+ * @return The metadata of this entity, or {@code null} if none exist.
*/
public EntityMetadata getMetadata() {
// CONSIDER: For entities that don't have an eai:acl field, which is
- // uncommon, but does happen at least in the case of a DeploymentClient
+ // uncommon but does happen at least in the case of a DeploymentClient
// that is not enabled, we return null. A slightly friendlier option
// would be to return a metadata instance that defaults all values?
if (!containsKey("eai:acl")) return null;
@@ -273,6 +276,8 @@ public EntityMetadata getMetadata() {
* @return The string value associated with the specified key.
*/
String getString(String key) {
+ if (toUpdate.containsKey(key))
+ return toUpdate.get(key).toString();
return getContent().getString(key);
}
@@ -285,6 +290,8 @@ String getString(String key) {
* @return The string value associated with the specified key.
*/
String getString(String key, String defaultValue) {
+ if (toUpdate.containsKey(key))
+ return toUpdate.get(key).toString();
return getContent().getString(key, defaultValue);
}
@@ -295,6 +302,9 @@ String getString(String key, String defaultValue) {
* @return The string array value associated with the specified key.
*/
String[] getStringArray(String key) {
+ if (toUpdate.containsKey(key)) {
+ return ((String)toUpdate.get(key)).split("\\|");
+ }
return getContent().getStringArray(key);
}
@@ -307,6 +317,8 @@ String[] getStringArray(String key) {
* @return The string array value associated with the specified key.
*/
String[] getStringArray(String key, String[] defaultValue) {
+ if (toUpdate.containsKey(key))
+ return getStringArray(key);
return getContent().getStringArray(key, defaultValue);
}
@@ -316,21 +328,33 @@ public boolean isEmpty() {
}
/**
- * Returns whether or not this entity is disabled. Available on almost
- * evey endpoint.
+ * Indicates whether this entity is disabled. This method is
+ * available on almost every endpoint.
*
- * @return Whether or not this entity is disabled.
+ * @return {@code true} if this entity is disabled, {@code false} if
+ * enabled.
*/
public boolean isDisabled() {
return getBoolean("disabled", false);
}
+
+ /**
+ * Returns whether this entity's name can be changed via {@link #update}.
+ *
+ * Most entity names cannot be changed in this way.
+ * @return false.
+ */
+ protected boolean isNameChangeAllowed() {
+ return false;
+ }
/** {@inheritDoc} */
public Set keySet() {
return getContent().keySet();
}
- @Override Entity load(AtomObject value) {
+ @Override
+ Entity load(AtomObject value) {
super.load(value);
AtomEntry entry = (AtomEntry)value;
if (entry == null) {
@@ -354,41 +378,97 @@ public void putAll(Map extends String, ? extends Object> map) {
/** {@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 = AtomFeed.parse(response.getContent());
+ AtomFeed feed;
+ try {
+ feed = AtomFeed.parseStream(response.getContent());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
int count = feed.entries.size();
- assert(count == 0 || count == 1);
+ 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;
}
- /**
- * Performs this entity's reload action.
- */
- public void reload() {
- service.get(actionPath("reload"));
- invalidate();
- }
-
/** {@inheritDoc} */
public Object remove(Object key) {
throw new UnsupportedOperationException();
}
+ /**
+ * Sets the local cache update value. Writing is deferred until
+ * {@code update} has been called.
+ *
+ * @param key The key to set.
+ * @param value The default value.
+ */
+ void setCacheValue(String key, Object value) {
+ toUpdate.put(key, value);
+ }
+
/** {@inheritDoc} */
public int size() {
return getContent().size();
}
/**
- * Updates the entity with the specified arguments.
+ * Updates the entity with the values you previously set using the setter
+ * methods, and any additional specified arguments. The specified arguments
+ * take precedent over the values that were set using the setter methods.
*
- * @param args The arguments being updated.
+ * @param args The arguments to update.
*/
public void update(Map args) {
- service.post(actionPath("edit"), args);
+ if (!toUpdate.isEmpty() || !args.isEmpty()) {
+ // Merge cached setters and live args together before updating.
+ Map mergedArgs =
+ new LinkedHashMap();
+ mergedArgs.putAll(toUpdate);
+ mergedArgs.putAll(args);
+
+ if (mergedArgs.containsKey("name") && !isNameChangeAllowed()) {
+ throw new IllegalStateException("Cannot set 'name' on an existing entity.");
+ }
+
+ service.post(actionPath("edit"), mergedArgs);
+ toUpdate.clear();
+ invalidate();
+ }
+ }
+
+ /**
+ * Updates the entity with the accumulated arguments, established by the
+ * individual setter methods for each specific entity class.
+ */
+ @SuppressWarnings("unchecked")
+ public void update() {
+ update(Collections.EMPTY_MAP);
+ }
+
+
+ /**
+ * Update the access control list (ACL) properties for this entity,
+ *
+ * @param args: Properties to update for this entity.
+ * Required Properties in 'args'
+ * - `owner`: The Splunk username, such as "admin". A value of "nobody" means no specific user.
+ * - `sharing`: A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
+ */
+ public void aclUpdate(Map args){
+ if(!args.containsKey("sharing")){
+ throw new IllegalArgumentException("Required argument 'sharing' is missing.");
+ }
+ if(!args.containsKey("owner")){
+ throw new IllegalArgumentException("Required argument 'owner' is missing.");
+ }
+ service.post(actionPath("acl"), args);
invalidate();
}
diff --git a/splunk/src/main/java/com/splunk/EntityCollection.java b/splunk/src/main/java/com/splunk/EntityCollection.java
new file mode 100644
index 00000000..a0378d60
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/EntityCollection.java
@@ -0,0 +1,152 @@
+/*
+ * 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.LinkedList;
+import java.util.Map;
+
+/**
+ * The {@code EntityCollection} class represents a collection of Splunk
+ * entities.
+ *
+ * @param The type of members in the collection.
+ */
+public class EntityCollection extends ResourceCollection {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The entity's endpoint.
+ */
+ EntityCollection(Service service, String path) {
+ super(service, path, Entity.class);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The entity's endpoint.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them (see {@link CollectionArgs}).
+ */
+ EntityCollection(Service service, String path, Args args) {
+ super(service, path, Entity.class, args);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The entity's endpoint.
+ * @param itemClass The entity's class.
+ */
+ EntityCollection(Service service, String path, Class itemClass) {
+ super(service, path, itemClass);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The entity's endpoint.
+ * @param itemClass The entity's class.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them (see {@link CollectionArgs}).
+ */
+ public EntityCollection(Service service, String path, Class itemClass, Args args) {
+ super(service, path, itemClass, args);
+ }
+
+ /**
+ * Creates an entity in this collection.
+ *
+ * @param name The name of the entity.
+ * @return The entity.
+ */
+ public T create(String name) {
+ return create(name, (Map)null);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Removes an entity from this collection.
+ *
+ * @param key The name of the entity to remove.
+ * @return The collection.
+ * @throws SplunkException The exception "AMBIGUOUS" if the collection
+ * contains more than one entity with the specified key. Disambiguation is
+ * done through a similar method,
+ * {@code remove(Object key, HashMapnamespace}, which uses
+ * the namespace to perform the disambiguation.
+ */
+ public T remove(String key) {
+ validate();
+ if (!containsKey(key)) return null;
+ LinkedList entities = items.get(key);
+ if (entities != null && entities.size() > 1) {
+ throw new SplunkException(SplunkException.AMBIGUOUS,
+ "Key has multiple values, specify a namespace");
+ }
+ if (entities == null) return null;
+ T entity = entities.get(0);
+ entity.remove();
+ // by invalidating any access to items will get refreshed
+ invalidate();
+ return entity;
+ }
+
+ /**
+ * Removes an entity from this collection, with a namespace restriction.
+ *
+ * @param key The name of the entity to remove.
+ * @param namespace The namespace restriction within the collection.
+ * @return This collection.
+ */
+ public T remove(String key, Args namespace) {
+ Util.ensureNamespaceIsExact(namespace);
+ validate();
+
+ if (!containsKey(key)) return null;
+ LinkedList entities = items.get(key);
+ String pathMatcher = service.fullpath("", namespace);
+ if (entities == null || entities.size() == 0) return null;
+ for (T entity: entities) {
+ if (entity.path.startsWith(pathMatcher)) {
+ entity.remove();
+ // By invalidating, any access to items will get refreshed
+ invalidate();
+ return entity;
+ }
+ }
+ return null;
+ }
+}
diff --git a/splunk/com/splunk/EntityMetadata.java b/splunk/src/main/java/com/splunk/EntityMetadata.java
similarity index 55%
rename from splunk/com/splunk/EntityMetadata.java
rename to splunk/src/main/java/com/splunk/EntityMetadata.java
index 6829cf49..b36b775a 100644
--- a/splunk/com/splunk/EntityMetadata.java
+++ b/splunk/src/main/java/com/splunk/EntityMetadata.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,15 @@
package com.splunk;
/**
- * Provides access to the metadata properties of a corresponding entity.
- * Instances of this class are obtained via {@code Entity.getMetadata}.
+ * The {@code EntityMetadata} class provides access to the metadata properties
+ * of a corresponding entity. Use {@code Entity.getMetadata} to obtain an
+ * instance of this class.
*/
public class EntityMetadata {
private Entity entity;
/**
- * Clas constructor.
+ * Class constructor.
*
* @param entity This entity.
*/
@@ -33,101 +34,107 @@ public class EntityMetadata {
}
/**
- * Returns whether or not this entity's permission can be changed.
+ * Indicates whether this entity's permission can be changed.
*
- * @return Whether or not this entity's permission can be changed.
+ * @return {@code true} if this entity's permission can be changed,
+ * {@code false} if not.
*/
public boolean canChangePermissions() {
return getEaiAcl().getBoolean("can_change_perms", false);
}
/**
- * Returns whether or not the resource can be shared via an app.
+ * Indicates whether this entity can be shared via an app.
*
- * @return Whether or not the resource can be shared via an app.
+ * @return {@code true} if this entity can be shared via an app,
+ * {@code false} if not.
*/
public boolean canShareApp() {
return getEaiAcl().getBoolean("can_share_app", false);
}
/**
- * Returns whether or not the resource can be shared globally.
+ * Indicates whether the entity can be shared globally.
*
- * @return Whether or not the resource can be shared globally.
+ * @return {@code true} if this entity can be shared globally,
+ * {@code false} if not.
*/
public boolean canShareGlobal() {
return getEaiAcl().getBoolean("can_share_global", false);
}
/**
- * Returns whether or not the resource can be shared to a specific user.
+ * Indicates whether the entity can be shared to a specific user.
*
- * @return Whether ot nor the resource can be shared to a specific user.
+ * @return {@code true} if this entity can be shared to a specific user,
+ * {@code false} if not.
*/
public boolean canShareUser() {
return getEaiAcl().getBoolean("can_share_user", false);
}
/**
- * Returns whether or not this entity can be modified.
+ * Indicates whether this entity can be modified.
*
- * @return Whether or not this entity can be modified.
+ * @return {@code true} if this entity can be modified,
+ * {@code false} if not.
*/
public boolean canWrite() {
return getEaiAcl().getBoolean("can_write", false);
}
/**
- * Returns the app context of this resource.
+ * Returns the app context of this entity.
*
- * @return The app context of this resource.
+ * @return The app context of this entity.
*/
public String getApp() {
return getEaiAcl().getString("app", "system");
}
/**
- * Returns the record containing all the metadata information.
+ * Returns a record containing all of the metadata information
+ * for this entity.
*
- * @return The record containing all the metadata information.
+ * @return The record containing the metadata information.
*/
Record getEaiAcl() {
return (Record)entity.validate().get("eai:acl");
}
/**
- * Returns the resource owner's username.
+ * Returns the username of the entity owner.
*
- * @return The resource owner's username.
+ * @return The entity owner's username.
*/
public String getOwner() {
return getEaiAcl().getString("owner");
}
/**
- * Returns this entity's permissions. These permissions represent an
+ * Returns this entity's permissions, which represent an
* allowable inclusive action:list-of-roles map.
*
* @return This entity's permissions map.
*/
public Record getPermissions() {
- return getEaiAcl().getValue("perms", null);
+ return getEaiAcl().getValue("perms", null);
}
/**
- * Returns how this resource is shared. Sharing values are from the list
- * app, global and user.
+ * Returns how this entity is shared (app, global, and/or user).
*
- * @return How this resource is shared.
+ * @return Values that indicate how this entity is shared.
*/
public String getSharing() {
return getEaiAcl().getString("sharing");
}
/**
- * Returns whether or not this entity can be modified.
+ * Indicates whether this entity can be modified.
*
- * @return Whether or not this entity can be modified.
+ * @return {@code true} if this entity can be modified,
+ * {@code false} if not.
*/
public boolean isModifiable() {
return getEaiAcl().getBoolean("modifiable", false);
diff --git a/splunk/src/main/java/com/splunk/EvalDataModelCalculation.java b/splunk/src/main/java/com/splunk/EvalDataModelCalculation.java
new file mode 100644
index 00000000..c425313b
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/EvalDataModelCalculation.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 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.Map;
+
+/**
+ * Represents a calculation on a data model object done by an eval.
+ */
+public class EvalDataModelCalculation extends DataModelCalculation {
+ private final String expression;
+
+ public EvalDataModelCalculation(String[] owner, String calculationID,
+ Map generatedFields, String comment,
+ boolean editable, String expression) {
+ super(owner, calculationID, generatedFields, comment, editable);
+ this.expression = expression;
+ }
+
+ /**
+ * @return eval expression specifying this calculation
+ */
+ public String getExpression() { return this.expression; }
+}
diff --git a/splunk/src/main/java/com/splunk/Event.java b/splunk/src/main/java/com/splunk/Event.java
new file mode 100644
index 00000000..a37b91bc
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/Event.java
@@ -0,0 +1,214 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * The {@code Event} class wraps an individual event or result that was returned
+ * by the {@link ResultsReader#getNextEvent} method.
+ *
+ * An event maps each field name to a list of zero of more values.
+ * These values can be accessed as either an array (using the {@link #getArray}
+ * method) or as a delimited string (using the {@link #get} method). We
+ * recommend accessing values as an array when possible.
+ *
+ * The delimiter for field values depends on the underlying result format.
+ * If the underlying format does not specify a delimiter, such as with the
+ * {@link ResultsReaderXml} class, the delimiter is a comma (,).
+ */
+public class Event extends HashMap {
+ private Map arrayValues = new HashMap();
+ private String segmentedRaw;
+
+ // Prevent non-SDK instantiation.
+ Event() {
+ // nothing
+ }
+
+ /**
+ * Sets the single value or delimited set of values for the specified
+ * field name.
+ *
+ * When setting a multi-valued field, use the
+ * {@link #putArray(String, String[])} method instead.
+ *
+ * @param key The field name.
+ * @param valueOrDelimitedValues The single values or delimited set of
+ * values.
+ */
+ String putSingleOrDelimited(String key, String valueOrDelimitedValues) {
+ return super.put(key, valueOrDelimitedValues);
+ }
+
+ /**
+ * Sets the values for the specified field name, with the assumption that
+ * the value delimiter is a comma (,).
+ *
+ * @param key The field name.
+ * @param values The delimited set of values.
+ */
+ void putArray(String key, String[] values) {
+ arrayValues.put(key, values);
+
+ // For backward compatibility with the Map interface
+ super.put(key, Util.join(",", values));
+ }
+
+ /**
+ * Sets the value for the XML element for the {@code _raw} field. This value
+ * is only used by the {@link ResultsReaderXml} class.
+ * @param value The text of the XML element.
+ */
+ void putSegmentedRaw(String value) {
+ segmentedRaw = value;
+ }
+
+ /**
+ * Returns the single value or delimited set of values for the specified
+ * field name, or {@code null} if the specified field is not present.
+ *
+ * When getting a multi-valued field, use the {@link #getArray(String)} or
+ * {@link #getArray(String, String)} method instead.
+ *
+ * @param key The field name.
+ * @return The single value or delimited set of values.
+ */
+ public String get(String key) {
+ return super.get(key);
+ }
+
+ /**
+ * Gets the values for the specified field name.
+ *
+ * Caution: This variant of {@link #getArray(String, String)} is
+ * unsafe for {@link ResultsReader} implementations that require a
+ * delimiter. Therefore, this method should only be used for results that
+ * are returned by {@link ResultsReaderXml}. For other readers, use the
+ * {@link #getArray(String, String)} method instead.
+ *
+ * If the underlying {@link ResultsReader} object has no delimiter, the
+ * original array of values is returned. If the object does have a
+ * delimiter, the single/delimited value is assumed to be a single value and
+ * is returned as a single-valued array.
+ *
+ * @param key The field name.
+ * @return The original array of values if there is no delimiter, or the
+ * single-valued array.
+ */
+ public String[] getArray(String key) {
+ String[] arrayValue = arrayValues.get(key);
+ if (arrayValue != null) {
+ return arrayValue;
+ }
+
+ String singleValue = super.get(key);
+ if (singleValue == null) {
+ return null;
+ }
+ return new String[] { singleValue };
+ }
+
+ /**
+ * Gets the values for the specified field name.
+ *
+ * The delimiter must be determined empirically based on the search
+ * string and the data format of the index. The delimiter can differ
+ * between fields in the same {@link Event} object.
+ *
+ * The delimiter is ignored for {@link ResultsReader} implementations
+ * that do not require a delimiter, such as {@link ResultsReaderXml}.
+ *
+ * If the underlying {@link ResultsReader} object has no delimiter, the
+ * original array of values is returned (and the specified delimiter is
+ * ignored). If the object does have a delimiter, the
+ * single/delimited value is split based on the specified delimiter and is
+ * returned as an array.
+ *
+ * @param key The field name.
+ * @param delimiter The delimiter.
+ * @return The original array of values if there is no delimiter, or the
+ * array of values split by delimiter.
+ */
+ public String[] getArray(String key, String delimiter) {
+ String[] arrayValue = arrayValues.get(key);
+ if (arrayValue != null) {
+ return arrayValue;
+ }
+
+ String delimitedValues = super.get(key);
+ if (delimitedValues == null) {
+ return null;
+ }
+ return delimitedValues.split(Pattern.quote(delimiter));
+ }
+
+ /**
+ * Gets the XML markup for the {@code "_raw"} field value. This value
+ * is only used by the {@link ResultsReaderXml} class.
+ *
+ * The return value is different than that of {@code get("_raw")}
+ * in that this segmented raw value is an XML fragment that includes all
+ * markup such as XML tags and escaped characters.
+ *
+ * For example, {@code get("_raw")} returns this:
+ *
+ * The {@code getSegmentedRaw} method returns this:
+ *
+ * {@code "http://localhost:8000/en-US/app/search/flashtimeline?q=search%20search%20index%3D_internal%20%7C%20head%2010&earliest=rt-1h&latest=rt"}
+ * @return the segmented raw xml including tags and escaped characters.
+ */
+ public String getSegmentedRaw() {
+ if (segmentedRaw == null) {
+ // ResultsReaderXml will always set this to not null. Using this
+ // method for other result reader is not supported.
+ throw new UnsupportedOperationException(
+ "The value is not available. Use ResultsReaderXml instead.");
+ }
+ return segmentedRaw;
+ }
+ // === Read Only ===
+
+ @Override
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object clone() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String put(String key, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void putAll(Map extends String, ? extends String> m) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/EventType.java b/splunk/src/main/java/com/splunk/EventType.java
new file mode 100644
index 00000000..4766f256
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/EventType.java
@@ -0,0 +1,142 @@
+/*
+ * 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.Map;
+
+/**
+ * The {@code EventType} class represents an event type.
+ */
+public class EventType extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The event type endpoint.
+ */
+ EventType(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the description of this event type.
+ *
+ * @return The description of this event type.
+ */
+ public String getDescription() {
+ return getString("description", null);
+ }
+
+ /**
+ * Returns the priority of this event type. The range is 1 to 10, with 1
+ * being the highest priority.
+ *
+ * @return The priority of this event type.
+ */
+ public int getPriority() {
+ return getInteger("priority", -1);
+ }
+
+ /**
+ * Returns the search terms for this event type.
+ *
+ * @return The search terms for this event type.
+ */
+ public String getSearch() {
+ return getString("search", null);
+ }
+
+ /**
+ * @deprecated Use tags.conf.spec file to assign tags to groups of events
+ * with related field values.
+ *
+ * Returns the list of tags for this event type.
+ *
+ * @return The list of tags for this event type.
+ */
+ public String [] getTags() {
+ return getStringArray("tags", null);
+ }
+
+ /**
+ * Sets the description of the event type.
+ *
+ * @param description The description of the event type.
+ */
+ public void setDescription(String description) {
+ setCacheValue("description", description);
+ }
+
+ /**
+ * Sets whether the event type is enabled or disabled.
+ *
+ * Note: Using this method requires you to restart Splunk before this
+ * setting takes effect. To avoid restarting Splunk, use the
+ * {@code Entity.disable} and {@code Entity.enable} methods instead, which
+ * take effect immediately.
+ * @see Entity#disable
+ * @see Entity#enable
+ * @param disabled The boolean flag
+ */
+ public void setDisabled(boolean disabled) {
+ setCacheValue("disabled", disabled);
+ }
+
+ /**
+ * Sets the priority of the event type. Valid values are from 1 to 10, with
+ * 1 being the highest priority.
+ *
+ * @param priority The priority of the event type.
+ */
+ public void setPriority(int priority) {
+ setCacheValue("priority", priority);
+ }
+
+ /**
+ * Sets the search string.
+ *
+ * @param search The search string.
+ */
+ public void setSearch(String search) {
+ setCacheValue("search", search);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public void update(Map 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() {
+ // If not present in the update keys, add required attribute as long
+ // as one pre-existing update pair exists
+ if (toUpdate.size() > 0 && !toUpdate.containsKey("search")) {
+ setCacheValue("search", getSearch());
+ }
+ super.update();
+ }
+}
+
diff --git a/splunk/com/splunk/EventTypeCollection.java b/splunk/src/main/java/com/splunk/EventTypeCollection.java
similarity index 56%
rename from splunk/com/splunk/EventTypeCollection.java
rename to splunk/src/main/java/com/splunk/EventTypeCollection.java
index 55b95046..516c2efc 100644
--- a/splunk/com/splunk/EventTypeCollection.java
+++ b/splunk/src/main/java/com/splunk/EventTypeCollection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -19,24 +19,35 @@
import java.util.Map;
/**
- * Representation of a collection of event types.
+ * The {@code EventTypeCollection} class represents a collection of event types.
*/
public class EventTypeCollection extends EntityCollection {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
*/
EventTypeCollection(Service service) {
super(service, "saved/eventtypes", EventType.class);
}
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them (see {@link CollectionArgs}).
+ */
+ EventTypeCollection(Service service, Args args) {
+ super(service, "saved/eventtypes", EventType.class, args);
+ }
+
/**
* Creates an event type.
*
- * @param name The name of this new event type.
- * @param search The search string of this new event type.
+ * @param name The name of the event type.
+ * @param search The search string of the event type.
*
* @return The event type.
*/
@@ -45,12 +56,13 @@ public EventType create(String name, String search) {
}
/**
- * Create an event type.
+ * Creates an event type.
*
- * @param name The name of this new event type.
- * @param search The search string of this new event type.
- * @param args Optional arguments.
- * @return the 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);
diff --git a/splunk/src/main/java/com/splunk/ExportResultsStream.java b/splunk/src/main/java/com/splunk/ExportResultsStream.java
new file mode 100644
index 00000000..c56067dd
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/ExportResultsStream.java
@@ -0,0 +1,31 @@
+/*
+ * 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.FilterInputStream;
+import java.io.InputStream;
+
+/**
+ * The {@code ExportResultsStream} class represents a stream constructed by the
+ * {@link Service#export} method.
+ *
+ */
+class ExportResultsStream extends FilterInputStream {
+ public ExportResultsStream(InputStream stream) {
+ super(stream);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/FieldType.java b/splunk/src/main/java/com/splunk/FieldType.java
new file mode 100644
index 00000000..8f78a469
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/FieldType.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2014 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.HashMap;
+import java.util.Map;
+
+/**
+ * Represents the type of a field in a data model object.
+ */
+public enum FieldType {
+ STRING {
+ public String toString() { return "string"; }
+ },
+ NUMBER {
+ public String toString() { return "number"; }
+ },
+ BOOLEAN {
+ public String toString() { return "boolean"; }
+ },
+ IPV4 {
+ public String toString() { return "ipv4"; }
+ },
+ TIMESTAMP {
+ public String toString() { return "timestamp"; }
+ },
+ CHILDCOUNT {
+ public String toString() { return "childcount"; }
+ },
+ OBJECTCOUNT {
+ public String toString() { return "objectcount"; }
+ },
+ UNDEFINED {
+ public String toString() {
+ throw new UnsupportedOperationException("No serialization for undefined field type.");
+ }
+ };
+
+ private final static Map typeLookup = new HashMap() {{
+ put("string", STRING);
+ put("number", NUMBER);
+ put("boolean", BOOLEAN);
+ put("ipv4", IPV4);
+ put("timestamp", TIMESTAMP);
+ put("childcount", CHILDCOUNT);
+ put("objectcount", OBJECTCOUNT);
+ }};
+
+ public static FieldType parseType(String text) {
+ FieldType result = typeLookup.get(text.toLowerCase());
+ if (result == null) {
+ result = UNDEFINED;
+ }
+ return result;
+ }
+
+};
diff --git a/splunk/src/main/java/com/splunk/FiredAlert.java b/splunk/src/main/java/com/splunk/FiredAlert.java
new file mode 100644
index 00000000..b9b1c151
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/FiredAlert.java
@@ -0,0 +1,148 @@
+/*
+ * 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.Date;
+
+/**
+ * The {@code FiredAlert} class represents a fired alert.
+ */
+public class FiredAlert extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The fired alert endpoint.
+ */
+ FiredAlert(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns this alert's actions (such as notifying by email, running a
+ * script, adding to RSS, tracking in Alert Manager, and enabling
+ * summary indexing).
+ *
+ * @return The alert actions, or {@code null} if not available.
+ */
+ public String[] getAction() {
+ return getStringArray("actions", null);
+ }
+
+ /**
+ * Returns this alert's type.
+ *
+ * @return The alert type, or {@code null} if not available.
+ */
+ public String getAlertType() {
+ return getString("alert_type", null);
+ }
+
+ /**
+ * Returns the rendered expiration time for this alert.
+ * This method is available in Splunk 4.3 and later.
+ *
+ * @return This alert's rendered expiration time, or {@code null} if not
+ * available.
+ */
+ public String getExpirationTime() {
+ return getString("expiration_time_rendered", null);
+ }
+
+ /**
+ * Returns the rendered expiration time for this alert,
+ * parsed as a Date object.
+ * This method is available in Splunk 4.3 and later.
+ *
+ * @return This alert's rendered expiration time, or {@code null} if not
+ * available.
+ */
+ public Date getParsedExpirationTime() {
+ return getDate("expiration_time_rendered", null);
+ }
+
+ /**
+ * Returns the saved search for this alert.
+ *
+ * @return The saved search name, or {@code null} if not available.
+ */
+ public String getSavedSearchName() {
+ return getString("savedsearch_name", null);
+ }
+
+ /**
+ * Returns this alert's severity on a scale of 1 to 10, with 1 being the
+ * highest severity.
+ *
+ * @return This alert's severity, or -1 if the value is not specified.
+ */
+ public int getSeverity() {
+ return getInteger("severity", -1);
+ }
+
+ /**
+ * Returns this alert's search ID (SID).
+ *
+ * @return This alert's SID, or {@code null} if not available.
+ */
+ public String getSid() {
+ return getString("sid", null);
+ }
+
+ /**
+ * Returns the count of triggered alerts.
+ * This method is available in Splunk 4.3 and later.
+ *
+ * @return The number of triggered alerts, or -1 if not specified.
+ */
+ public int getTriggeredAlertCount() {
+ return getInteger("triggered_alerts", -1);
+ }
+
+ /**
+ * Returns the time this alert was triggered.
+ *
+ * @return This alert's trigger time, or {@code null} if not available.
+ */
+ public Date getTriggerTime() {
+ return getDate("trigger_time", null);
+ }
+
+ /**
+ * Returns this alert's rendered trigger time.
+ * This method is available in Splunk 4.3 and later.
+ *
+ * @return This alert's trigger time, or {@code null} if not available.
+ */
+ public Date getTriggerTimeRendered() {
+ return getDate("trigger_time_rendered", null);
+ }
+
+ /**
+ * Indicates whether the result is a set of events (digest) or a single
+ * event (per result).
+ *
+ * This method is available in Splunk 4.3 and later.
+ *
+ * @return {@code true} if the result is a digest, {@code false} if per
+ * result.
+ */
+ public boolean isDigestMode() {
+ return getBoolean("digest_mode", false);
+ }
+}
diff --git a/splunk/com/splunk/OutputServer.java b/splunk/src/main/java/com/splunk/FiredAlertGroup.java
similarity index 51%
rename from splunk/com/splunk/OutputServer.java
rename to splunk/src/main/java/com/splunk/FiredAlertGroup.java
index 915c774e..7d6b0994 100644
--- a/splunk/com/splunk/OutputServer.java
+++ b/splunk/src/main/java/com/splunk/FiredAlertGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -15,29 +15,29 @@
*/
package com.splunk;
-
/**
- * Representation of an output server.
+ * The {@code FiredAlertGroup} class represents a group of fired alerts, which
+ * are the alerts for a given saved search.
*/
-public class OutputServer extends Entity {
+public class FiredAlertGroup extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
- * @param path The output server endpoint.
+ * @param service The connected {@code Service} instance.
+ * @param path The fired alert endpoint.
*/
- OutputServer(Service service, String path) {
+ FiredAlertGroup(Service service, String path) {
super(service, path);
}
/**
- * Returns this server's all-connections object.
+ * Returns a group of fired alerts for a given saved search.
*
- * @return This server's all-connections object.
+ * @return The fired alerts in the group.
*/
- public OutputServerAllConnections allConnections() {
- return new OutputServerAllConnections(
- service, path + "/allconnections");
+ public EntityCollection getAlerts() {
+ return new EntityCollection(
+ service, this.path, FiredAlert.class);
}
}
diff --git a/splunk/src/main/java/com/splunk/FiredAlertGroupCollection.java b/splunk/src/main/java/com/splunk/FiredAlertGroupCollection.java
new file mode 100644
index 00000000..875accd5
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/FiredAlertGroupCollection.java
@@ -0,0 +1,44 @@
+/*
+ * 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;
+/**
+ * The {@code FiredAlertGroupCollection} class represents a collection of fired
+ * alert groups.
+ */
+public class FiredAlertGroupCollection
+ extends EntityCollection{
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ FiredAlertGroupCollection(Service service) {
+ super(service, "alerts/fired_alerts", FiredAlertGroup.class);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them (see {@link CollectionArgs}).
+ */
+ FiredAlertGroupCollection(Service service, Args args) {
+ super(service, "alerts/fired_alerts", FiredAlertGroup.class, args);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/GeoIPDataModelCalculation.java b/splunk/src/main/java/com/splunk/GeoIPDataModelCalculation.java
new file mode 100644
index 00000000..cad9f5bf
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/GeoIPDataModelCalculation.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 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.Map;
+
+/**
+ * Represents a GeoIP lookup on a data model object, which uses an input
+ * field to add geographic information to the output.
+ */
+
+public class GeoIPDataModelCalculation extends DataModelCalculation {
+ private final String inputField;
+
+ GeoIPDataModelCalculation(String[] ownerLineage, String calculationID,
+ Map generatedFields, String comment,
+ boolean editable, String inputField) {
+ super(ownerLineage, calculationID, generatedFields, comment, editable);
+ this.inputField = inputField;
+ }
+
+ /**
+ * @return field to do GeoIP lookup on
+ */
+ public String getInputField() { return this.inputField; }
+}
diff --git a/splunk/com/splunk/HttpException.java b/splunk/src/main/java/com/splunk/HttpException.java
similarity index 67%
rename from splunk/com/splunk/HttpException.java
rename to splunk/src/main/java/com/splunk/HttpException.java
index 4323827e..4bdd7d17 100644
--- a/splunk/com/splunk/HttpException.java
+++ b/splunk/src/main/java/com/splunk/HttpException.java
@@ -19,6 +19,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
+import java.io.*;
+
/**
* Thrown for HTTP responses that return an error status code.
*/
@@ -41,15 +43,38 @@ public class HttpException extends RuntimeException {
static HttpException create(ResponseMessage response) {
int status = response.getStatus();
- // Attempt to read the error detail from the error response content.
- String detail = "";
+ StringBuilder s = new StringBuilder();
+ InputStreamReader r;
+ try {
+ r = new InputStreamReader(response.getContent(), "UTF-8");
+ } catch (UnsupportedEncodingException e1) {
+ throw new AssertionError("How does your system not support UTF-8?");
+ }
+
+ int c = -1;
+ while (true) {
+ try {
+ c = r.read();
+ } catch (IOException e1) {
+ // Not much to be done here if that stream is bad...
+ }
+ if (c == -1) break;
+
+ s.appendCodePoint(c);
+ }
+
+ // Initialize detail with raw response data. Prevents XML parser failures.
+ String detail = s.toString();
try {
- Document document = Xml.parse(response.getContent());
+ // Attempt to read the error detail from the error response content as XML
+ Document document = Xml.parse(new ByteArrayInputStream(detail.getBytes()), true);
NodeList msgs = document.getElementsByTagName("msg");
if (msgs.getLength() > 0)
detail = msgs.item(0).getTextContent();
}
- catch (Exception e) {} // Couldn't get detail
+ catch (Exception e) {
+ // Not an XML document; keep the raw string.
+ }
String message = String.format("HTTP %d", status);
diff --git a/splunk/src/main/java/com/splunk/HttpService.java b/splunk/src/main/java/com/splunk/HttpService.java
new file mode 100644
index 00000000..70b99269
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/HttpService.java
@@ -0,0 +1,614 @@
+/*
+ * 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 javax.net.ssl.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.*;
+import java.security.cert.X509Certificate;
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * The {@code HttpService} class represents a generic HTTP service at a given
+ * address ({@code host:port}), accessed using a given protocol scheme
+ * ({@code http} or {@code https}).
+ */
+public class HttpService {
+ // For debugging purposes
+ private static final boolean VERBOSE_REQUESTS = false;
+ protected static SSLSecurityProtocol sslSecurityProtocol = null;
+
+ /**
+ * Boolean flag for validating certificates at either of the sides (client/server).
+ * If true, then it will check and validate relevant certificates otherwise, in case of false, it will accept all certificates.
+ * For PROD environment, TRUE is strongly recommended, whereas working in localhost OR development environment, FALSE is used.
+ * Default Value: TRUE
+ */
+ protected static boolean validateCertificates = true;
+
+ private static SSLSocketFactory sslSocketFactory = createSSLFactory();
+ private static String HTTPS_SCHEME = "https";
+ private static String HTTP_SCHEME = "http";
+ private static List VALID_HOSTS = new ArrayList(Arrays.asList("localhost", "127.0.0.1", "::1"));
+
+ private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() {
+ public boolean verify(String s, SSLSession sslSession) {
+ if(VALID_HOSTS.contains(s)){
+ return true;
+ } else {
+ HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
+ return hv.verify(s, sslSession);
+ }
+ }
+ };
+
+ /**
+ * A variable to hold an optional custom HTTPS handler
+ */
+ protected URLStreamHandler httpsHandler = null;
+
+ /**
+ * The scheme used to access the service.
+ */
+ protected String scheme = "https";
+
+ /**
+ * The host name of the service.
+ */
+ protected String host = "localhost";
+
+ /**
+ * The port number of the service.
+ */
+ protected int port = 8089;
+
+ protected Integer connectTimeout = null;
+ protected Integer readTimeout = null;
+
+ private String prefix = null;
+
+ static Map defaultHeader = new HashMap() {{
+ put("User-Agent", "splunk-sdk-java/1.9.5");
+ put("Accept", "*/*");
+ }};
+
+ protected Map customHeaders = new HashMap<>();
+
+ protected SimpleCookieStore cookieStore = new SimpleCookieStore();
+
+ /**
+ * Constructs a new {@code HttpService} instance.
+ */
+ public HttpService() {
+ }
+
+ /**
+ * Constructs a new {@code HttpService} instance at the given host.
+ *
+ * @param host The host name of the service.
+ */
+ public HttpService(String host) {
+ this.host = host;
+ }
+
+ /**
+ * Constructs a new {@code HttpService} instance at the given host and port.
+ *
+ * @param host The host name of the service.
+ * @param port The port number of the service.
+ */
+ public HttpService(String host, int port) {
+ this.host = host;
+ this.port = port;
+ }
+
+ /**
+ * Constructs a new {@code HttpService} instance using the given host,
+ * port, and scheme.
+ *
+ * @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}).
+ */
+ public HttpService(String host, int port, String scheme) {
+ this.host = host;
+ this.port = port;
+ this.scheme = scheme;
+ }
+
+ /**
+ * Constructs a new {@code HttpService} 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 A custom URL Stream handler.
+ */
+ public HttpService(String host, int port, String scheme,
+ URLStreamHandler httpsHandler) {
+ this.host = host;
+ this.port = port;
+ this.scheme = scheme;
+ this.httpsHandler = httpsHandler;
+ }
+
+ // Returns the count of arguments in the given {@code args} map.
+ private static int count(Map args) {
+ if (args == null) return 0;
+ return args.size();
+ }
+
+ /**
+ * Issues an HTTP GET request against the service using a given path.
+ *
+ * @param path The request path.
+ * @return The HTTP response.
+ */
+ public ResponseMessage get(String path) {
+ return send(path, new RequestMessage("GET"));
+ }
+
+ /**
+ * Issues an HTTP GET request against the service using a given path and
+ * query arguments.
+ *
+ * @param path The request path.
+ * @param args The query arguments.
+ * @return The HTTP response.
+ */
+ public ResponseMessage get(String path, Map args) {
+ if (count(args) > 0)
+ path = path + "?" + Args.encode(args);
+ RequestMessage request = new RequestMessage("GET");
+ return send(path, request);
+ }
+
+ /**
+ * Returns the host name of this service.
+ *
+ * @return The host name.
+ */
+ public String getHost() {
+ return this.host;
+ }
+
+ /**
+ * Returns the port number of this service.
+ *
+ * @return The port number.
+ */
+ public int getPort() {
+ return this.port;
+ }
+
+ /**
+ * Sets Custom Headers of this service
+ *
+ * @param headers The custom headers.
+ */
+ public void setCustomHeaders(Map headers) {
+ if (Objects.nonNull(headers)) {
+ customHeaders = headers;
+ }
+ }
+
+ /**
+ * Returns the SSL security protocol of this service.
+ *
+ * @return The SSL security protocol.
+ */
+ public static SSLSecurityProtocol getSslSecurityProtocol() {
+ return sslSecurityProtocol;
+ }
+
+ /**
+ * Sets the SSL security protocol of this service.
+ * @param securityProtocol The SSLSecurityProtocal instance
+ */
+ public static void setSslSecurityProtocol(SSLSecurityProtocol securityProtocol) {
+ // Only update the SSL_SOCKET_FACTORY if changing protocols
+ if (sslSecurityProtocol != securityProtocol) {
+ sslSecurityProtocol = securityProtocol;
+ sslSocketFactory = createSSLFactory();
+ }
+ }
+
+ /**
+ * Adds list of Cluster Master Hosts to the list of Valid Hosts for Hostname verification.
+ * @param searchHeadService Splunk SearchHead Service instance
+ */
+ public static void addClusterMasterURIsToHosts(Service searchHeadService){
+ VALID_HOSTS.addAll(searchHeadService.getClusterMasters());
+ }
+
+ /**
+ * Returns the URL prefix of this service, consisting of
+ * {@code scheme://host[:port]}.
+ *
+ * @return The URL prefix.
+ */
+ public String getPrefix() {
+ if (this.prefix == null)
+ this.prefix = String.format("%s://%s:%s",
+ this.scheme, this.host, this.port);
+ return this.prefix;
+ }
+
+ /**
+ * Returns the scheme used by this service.
+ *
+ * @return The scheme.
+ */
+ public String getScheme() {
+ return this.scheme;
+ }
+
+ /**
+ * Constructs a fully-qualified URL for this service using a given path.
+ *
+ * @param path The path to qualify.
+ * @return The fully-qualified URL for the service.
+ */
+ public URL getUrl(String path) {
+ try {
+ if (HTTPS_SCHEME.equals(getScheme()) && httpsHandler != null) {
+ // This branch is not currently covered by unit tests as I
+ // could not figure out a generic way to get the default
+ // HTTPS handler.
+ return new URL(getScheme(), getHost(), getPort(), path,
+ httpsHandler);
+ } else {
+ return new URL(getScheme(), getHost(), getPort(), path);
+ }
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Returns all the stored custom headers
+ *
+ * @return customHeaders The custom headers
+ */
+ public Map getCustomHeaders() {
+ return customHeaders;
+ }
+
+ /**
+ * Returns all the stored cookies
+ *
+ * @return All cookies as in a string in the format key=value; key=value; etc=etc
+ */
+ public String stringifyCookies() {
+ return cookieStore.getCookies();
+ }
+
+ /**
+ * Adds the passed cookie header to the cookieStore
+ *
+ * @param setCookieHeader The result from a getRequestHeader("Set-Cookie") call
+ */
+ public void addCookie(String setCookieHeader) {
+ cookieStore.add(setCookieHeader);
+ }
+
+ /**
+ * Removes all cookies from the cookieStore
+ */
+ public void removeAllCookies() {
+ cookieStore.removeAll();
+ }
+
+ /**
+ * Returns true if the cookieStore has any Splunk Authorization cookies, false otherwise
+ *
+ * @return True if there are cookies, false otherwise
+ */
+ public Boolean hasSplunkAuthCookies() {
+ return cookieStore.hasSplunkAuthCookie();
+ }
+
+ /**
+ * Returns the connect timeout used by this service.
+ *
+ * @return The timeout in milliseconds.
+ */
+ public Integer getConnectTimeout() {
+ return connectTimeout;
+ }
+
+ /**
+ * Sets a specified timeout value, in milliseconds, to be used when opening a communications link.
+ *
+ * @param connectTimeout timeout in milliseconds, a timeout of zero is interpreted as an infinite timeout.
+ */
+ public void setConnectTimeout(Integer connectTimeout) {
+ this.connectTimeout = connectTimeout;
+ }
+
+ /**
+ * Returns the read timeout used by this service.
+ *
+ * @return The timeout in milliseconds.
+ */
+ public Integer getReadTimeout() {
+ return readTimeout;
+ }
+
+ /**
+ * Sets a specified timeout value, in milliseconds, to be used when reading from a communications link.
+ *
+ * @param readTimeout timeout in milliseconds, a timeout of zero is interpreted as an infinite timeout.
+ */
+ public void setReadTimeout(Integer readTimeout) {
+ this.readTimeout = readTimeout;
+ }
+
+ /**
+ * Issues a POST request against the service using a given path.
+ *
+ * @param path The request path.
+ * @return The HTTP response.
+ */
+ public ResponseMessage post(String path) {
+ return post(path, null);
+ }
+
+ /**
+ * Issues a POST request against the service using a given path and
+ * form arguments.
+ *
+ * @param path The request path.
+ * @param args The form arguments.
+ * @return The HTTP response.
+ */
+ public ResponseMessage post(String path, Map args) {
+ RequestMessage request = new RequestMessage("POST");
+ request.getHeader().put(
+ "Content-Type", "application/x-www-form-urlencoded");
+ if (count(args) > 0)
+ request.setContent(Args.encode(args));
+ return send(path, request);
+ }
+
+ /**
+ * Issues a DELETE request against the service using a given path.
+ *
+ * @param path The request path.
+ * @return The HTTP response.
+ */
+ public ResponseMessage delete(String path) {
+ RequestMessage request = new RequestMessage("DELETE");
+ return send(path, request);
+ }
+
+ /**
+ * Issues a DELETE request against the service using a given path
+ * and query arguments.
+ *
+ * @param path The request path.
+ * @param args The query arguments.
+ * @return The HTTP response.
+ */
+ public ResponseMessage delete(String path, Map args) {
+ if (count(args) > 0)
+ path = path + "?" + Args.encode(args);
+ RequestMessage request = new RequestMessage("DELETE");
+ return send(path, request);
+ }
+
+ /**
+ * Opens a socket to this service.
+ *
+ * @return The socket.
+ * @throws IOException
+ */
+ Socket open() throws IOException {
+ if (this.scheme.equals("https")) {
+ return sslSocketFactory.createSocket(this.host, this.port);
+ }
+ return new Socket(this.host, this.port);
+ }
+
+ /**
+ * Issue an HTTP request against the service using a given path and
+ * request message.
+ *
+ * @param path The request path.
+ * @param request The request message.
+ * @return The HTTP response.
+ */
+ public ResponseMessage send(String path, RequestMessage request) {
+ // Construct a full URL to the resource
+ URL url = getUrl(path);
+ // Create and initialize the connection object
+ HttpURLConnection cn;
+ try {
+ cn = (HttpURLConnection) url.openConnection();
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ if (cn instanceof HttpsURLConnection) {
+ ((HttpsURLConnection) cn).setSSLSocketFactory(sslSocketFactory);
+ ((HttpsURLConnection) cn).setHostnameVerifier(HOSTNAME_VERIFIER);
+ }
+ cn.setUseCaches(false);
+ cn.setAllowUserInteraction(false);
+ cn.setConnectTimeout(connectTimeout == null ? 0 : connectTimeout);
+ cn.setReadTimeout(readTimeout == null ? 0 : readTimeout);
+
+ // Set the request method
+ String method = request.getMethod();
+ try {
+ cn.setRequestMethod(method);
+ } catch (ProtocolException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ // Add headers from request message
+ Map header = request.getHeader();
+ for (Entry entry : header.entrySet())
+ cn.setRequestProperty(entry.getKey(), entry.getValue());
+ // Add default headers that were absent from the request message
+ for (Entry entry : defaultHeader.entrySet()) {
+ String key = entry.getKey();
+ if (header.containsKey(key)) continue;
+ cn.setRequestProperty(key, entry.getValue());
+ }
+ // Add Custom Headers
+ for (Entry entry: customHeaders.entrySet()) {
+ String key = entry.getKey();
+ if (!header.containsKey(key)) {
+ cn.setRequestProperty(key, entry.getValue());
+ }
+ }
+
+ // Add cookies to header
+ cn.setRequestProperty("Cookie", cookieStore.getCookies());
+
+ // Write out request content, if any
+ try {
+ Object content = request.getContent();
+ if (content != null) {
+ cn.setDoOutput(true);
+ OutputStream stream = cn.getOutputStream();
+ OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8");
+ writer.write((String) content);
+ writer.close();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ if (VERBOSE_REQUESTS) {
+ System.out.format("%s %s => ", method, url.toString());
+ }
+
+ // Execute the request
+ try {
+ cn.connect();
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ int status;
+ try {
+ status = cn.getResponseCode();
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ InputStream input = null;
+ try {
+ input = status >= 400
+ ? cn.getErrorStream()
+ : cn.getInputStream();
+ } catch (IOException e) {
+ assert (false);
+ }
+
+ // Add cookies to cookie Store
+ Map> headers = cn.getHeaderFields();
+ if (headers.containsKey("Set-Cookie")) {
+ for (String cookieHeader : headers.get("Set-Cookie")) {
+ if (cookieHeader != null && cookieHeader.length() > 0)
+ cookieStore.add(cookieHeader);
+ }
+ }
+
+ ResponseMessage response = new ResponseMessage(status, input);
+
+ if (VERBOSE_REQUESTS) {
+ System.out.format("%d\n", status);
+ if (method.equals("POST")) {
+ System.out.println(" " + request.getContent());
+ }
+ }
+
+ if (status >= 400)
+ throw HttpException.create(response);
+
+ return response;
+ }
+
+ public static void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) {
+ if (sslSocketFactory == null)
+ throw new IllegalArgumentException("The sslSocketFactory cannot be null.");
+ HttpService.sslSocketFactory = sslSocketFactory;
+ }
+
+ public static SSLSocketFactory getSSLSocketFactory() {
+ return HttpService.sslSocketFactory;
+ }
+
+ public static void setValidateCertificates(boolean validateCertificate) {
+ // update the SSL_SOCKET_FACTORY if validateCertificates flag is changed
+ if (validateCertificates != validateCertificate) {
+ validateCertificates = validateCertificate;
+ sslSocketFactory = createSSLFactory();
+ }
+ }
+
+ public static SSLSocketFactory createSSLFactory() {
+
+ try {
+ SSLContext context;
+ if (sslSecurityProtocol != null) {
+ String contextStr = sslSecurityProtocol.toString().contains("SSL") ? "SSL" : "TLS";
+ context = SSLContext.getInstance(contextStr);
+ } else if (System.getProperty("java.version").compareTo("1.8") >= 0) {
+ context = SSLContext.getInstance("TLS");
+ } else {
+ context = SSLContext.getDefault();
+ }
+
+ if (validateCertificates) {
+ context.init(null, null, null);
+ // For now this check is set as null.
+ // TODO: Implementation logic for validating client certificate.
+ } else {
+ TrustManager[] trustAll = new TrustManager[]{
+ new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+ context.init(null, trustAll, null);
+ }
+
+ return context.getSocketFactory();
+ } catch (Exception e) {
+ throw new RuntimeException("Error setting up SSL socket factory: " + e, e);
+ }
+ }
+
+}
+
diff --git a/splunk/src/main/java/com/splunk/IPv4Comparison.java b/splunk/src/main/java/com/splunk/IPv4Comparison.java
new file mode 100644
index 00000000..f1ef9998
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/IPv4Comparison.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2014 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;
+
+/**
+ * Comparison operators that apply to IPv4 values in data models and pivots.
+ */
+public enum IPv4Comparison {
+ IS {
+ public String toString() { return "is"; }
+ },
+ CONTAINS {
+ public String toString() { return "contains"; }
+ },
+ IS_NOT {
+ public String toString() { return "isNot"; }
+ },
+ DOES_NOT_CONTAIN {
+ public String toString() { return "doesNotContain"; }
+ },
+ STARTS_WITH {
+ public String toString() { return "startsWith"; }
+ },
+ IS_NULL {
+ public String toString() { return "isNull"; }
+ },
+ IS_NOT_NULL {
+ public String toString() { return "isNotNull"; }
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/IPv4PivotFilter.java b/splunk/src/main/java/com/splunk/IPv4PivotFilter.java
new file mode 100644
index 00000000..9fe794d4
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/IPv4PivotFilter.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+import java.net.Inet4Address;
+
+/**
+ * Represents a filter on an IPv4 valued field in a pivot.
+ */
+public class IPv4PivotFilter extends PivotFilter {
+ private final IPv4Comparison comparison;
+ private final String comparisonValue;
+
+ IPv4PivotFilter(DataModelObject dataModelObject, String field, IPv4Comparison comparison, String comparisonValue) {
+ super(dataModelObject, field);
+ if (dataModelObject.getField(field).getType() != FieldType.IPV4) {
+ throw new IllegalArgumentException("Field " + field + " on the data model object was of type "
+ + dataModelObject.getField(field).getType().toString() + ", expected ipv4.");
+ }
+ this.comparison = comparison;
+ this.comparisonValue = comparisonValue;
+ }
+
+ @Override
+ JsonElement toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+
+ JsonObject filterRule = new JsonObject();
+ filterRule.add("comparator", new JsonPrimitive(this.comparison.toString()));
+ filterRule.add("compareTo", new JsonPrimitive(this.comparisonValue));
+
+ root.add("rule", filterRule);
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/Index.java b/splunk/src/main/java/com/splunk/Index.java
new file mode 100644
index 00000000..f39dd2e7
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/Index.java
@@ -0,0 +1,1118 @@
+/*
+ * 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.OutputStream;
+import java.net.Socket;
+import java.util.Date;
+
+/**
+ * The {@code Index} class represents an index.
+ */
+public class Index extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The index endpoint.
+ */
+ Index(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Creates a writable socket to this index.
+ *
+ * @return The writable socket.
+ * @throws IOException Throws exception if fails to write socket.
+ */
+ public Socket attach() throws IOException {
+ Receiver receiver = service.getReceiver();
+ return receiver.attach(getName());
+ }
+
+ /**
+ * Writes events to this index, reusing the connection.
+ * This method passes an output stream connected to the index to the
+ * {@code run} method of the {@code ReceiverBehavior} object, then handles
+ * setting up and tearing down the socket.
+ *
+ * For an example of how to use this method, see
+ * How to
+ * get data into Splunk on
+ * dev.splunk.com.
+ *
+ * @param behavior The body of a {@code try} block as an anonymous
+ * implementation of the {@code ReceiverBehavior} interface.
+ * @throws IOException The IOException class
+ */
+ public void attachWith(ReceiverBehavior behavior) throws IOException {
+ Socket socket = null;
+ OutputStream output = null;
+ try {
+ socket = attach();
+ output = socket.getOutputStream();
+ behavior.run(output);
+ output.flush();
+ } finally {
+ if (output != null) { output.close(); }
+ if (socket != null) { socket.close(); }
+ }
+ }
+
+ /**
+ * Creates a writable socket to this index.
+ *
+ * @param args Optional arguments for this stream. Valid parameters are:
+ * "host", "host_regex", "source", and "sourcetype".
+ * @return The socket.
+ * @throws IOException The IOException class
+ */
+ public Socket attach(Args args) throws IOException {
+ Receiver receiver = service.getReceiver();
+ return receiver.attach(getName(), args);
+ }
+
+ /**
+ * Cleans this index, which removes all events from it.
+ *
+ * @param maxSeconds The maximum number of seconds to wait before returning.
+ * A value of -1 means to wait forever.
+ * @throws SplunkException If cleaning timed out or
+ * if the thread was interrupted.
+ * @return This index.
+ */
+ public Index clean(int maxSeconds) {
+ Args saved = new Args();
+ saved.put("maxTotalDataSizeMB", getMaxTotalDataSizeMB());
+ saved.put("frozenTimePeriodInSecs", getFrozenTimePeriodInSecs());
+ try {
+ Args reset = new Args();
+ reset.put("maxTotalDataSizeMB", "1");
+ reset.put("frozenTimePeriodInSecs", "1");
+ update(reset);
+ rollHotBuckets();
+
+ long startTime = System.currentTimeMillis();
+ long endTime = startTime + (maxSeconds * 1000);
+ while (true) {
+ long timeLeft = endTime - System.currentTimeMillis();
+ if (timeLeft <= 0) {
+ break;
+ }
+ Thread.sleep(Math.min(1000, timeLeft));
+
+ if (this.getTotalEventCount() == 0) {
+ return this;
+ }
+ refresh();
+ }
+
+ throw new SplunkException(SplunkException.TIMEOUT,
+ "Index cleaning timed out");
+ }
+ catch (InterruptedException e)
+ {
+ SplunkException f = new SplunkException(
+ SplunkException.INTERRUPTED,
+ "Index cleaning interrupted.");
+ f.initCause(e);
+ throw f;
+ }
+ finally {
+ update(saved);
+ }
+ }
+
+ /**
+ * Indicates whether the data retrieved from this index has been
+ * UTF8-encoded.
+ *
+ * @return {@code true} if the retrieved data is in UTF8, {@code false} if
+ * not.
+ */
+ public boolean getAssureUTF8() {
+ return getBoolean("assureUTF8");
+ }
+
+ /**
+ * Returns the total size of all bloom filter files.
+ *
+ * @return The total size of all bloom filter files, in KB.
+ */
+ public int getBloomfilterTotalSizeKB() {
+ return getInteger("bloomfilterTotalSizeKB", 0);
+ }
+
+ /**
+ * Returns the suggested size of the .tsidx file for the bucket rebuild
+ * process.
+ * Valid values are: "auto", a positive integer, or a positive
+ * integer followed by "KB", "MB", or "GB".
+ *
+ * @return The suggested size of the .tsidx file for the bucket rebuild
+ * process.
+ */
+ public String getBucketRebuildMemoryHint() {
+ return getString("bucketRebuildMemoryHint");
+ }
+
+ /**
+ * Returns the absolute file path to the cold database for this index.
+ * This value may contain shell expansion terms.
+ *
+ * @return The absolute file path to the cold database, or {@code null} if
+ * not specified.
+ */
+ public String getColdPath() {
+ return getString("coldPath", null);
+ }
+
+ /**
+ * Returns the expanded absolute file path to the cold database for this
+ * index.
+ *
+ * @return The expanded absolute file path to the cold database, or
+ * {@code null} if not specified.
+ */
+ public String getColdPathExpanded() {
+ return getString("coldPath_expanded", null);
+ }
+
+ /**
+ * Returns the frozen archive destination path for this index.
+ *
+ * @return The frozen archive destination path, or {@code null} if not
+ * specified.
+ */
+ public String getColdToFrozenDir() {
+ return getString("coldToFrozenDir", null);
+ }
+
+ /**
+ * Returns the path to the archiving script.
+ *
For more info about archiving scripts, see the
+ * POST data/indexes endpoint in the REST API
+ * documentation.
+ * @see #getColdToFrozenDir
+ *
+ * @return The archiving script, or {@code null} if not specified.
+ */
+ public String getColdToFrozenScript() {
+ return getString("coldToFrozenScript", null);
+ }
+
+ /**
+ * Indicates whether raw data is compressed.
+ *
+ * @deprecated Splunk always compresses raw data.
+ * @return {@code true} if raw data is compressed, {@code false} if not.
+ */
+ public boolean getCompressRawdata() {
+ return getBoolean("compressRawdata");
+ }
+
+ /**
+ * Returns the current size of this index.
+ *
+ * @return The current size of the index, in MB.
+ */
+ public int getCurrentDBSizeMB() {
+ return getInteger("currentDBSizeMB");
+ }
+
+ /**
+ * Return the default index name of the Splunk instance.
+ *
+ * @return The default index name.
+ */
+ public String getDefaultDatabase() {
+ return getString("defaultDatabase");
+ }
+
+ /**
+ * Returns whether asynchronous "online fsck" bucket repair is enabled.
+ *
+ * When this feature is enabled, you don't have to wait for buckets to be
+ * repaired before starting Splunk, but you might notice a slight
+ * degradation in performance as a result.
+ * @return {@code true} if bucket repair is enabled, {@code false} if
+ * not.
+ */
+ public boolean getEnableOnlineBucketRepair() {
+
+ return getBoolean("enableOnlineBucketRepair");
+ }
+
+ /**
+ * Indicates whether real-time search is enabled for this index.
+ *
+ * @return {@code true} if real-time search is enabled, {@code false} if
+ * not.
+ */
+ public boolean getEnableRealtimeSearch() {
+ return getBoolean("enableRealtimeSearch");
+ }
+
+ /**
+ * Returns the maximum age for a bucket, after which the data in this index
+ * rolls to frozen. If archiving is necessary for frozen data, see the
+ * {@code coldToFrozen} attributes.
+ *
+ * @return The maximum age, in seconds, after which data rolls to frozen.
+ */
+ public int getFrozenTimePeriodInSecs() {
+ return getInteger("frozenTimePeriodInSecs");
+ }
+
+ /**
+ * Returns the absolute path to both hot and warm buckets for this index.
+ * This value may contain shell expansion terms.
+ *
+ * @return This index's absolute path to both hot and warm buckets, or
+ * {@code null} if not specified.
+ */
+ public String getHomePath() {
+ return getString("homePath", null);
+ }
+
+ /**
+ * Returns the expanded absolute path to both hot and warm buckets for this
+ * index.
+ *
+ * @return The expanded absolute path to both hot and warm buckets, or
+ * {@code null} if not specified.
+ */
+ public String getHomePathExpanded() {
+ return getString("homePath_expanded", null);
+ }
+
+ /**
+ * Returns the index thread for this index.
+ *
+ * @return The index thread.
+ */
+ public String getIndexThreads() {
+ return getString("indexThreads");
+ }
+
+ /**
+ * Returns the last initialization time for this index.
+ *
+ * @return The last initialization time, or {@code null} if not specified.
+ */
+ public String getLastInitTime() {
+ return getString("lastInitTime", null);
+ }
+
+ /**
+ * Returns the time that indicates a bucket age. When a warm or cold bucket
+ * is older than this, Splunk does not create or rebuild its bloomfilter.
+ * The valid format is number followed by a time unit ("s", "m", "h",
+ * or "d"). For example, "30d" for 30 days.
+ * @return String value
+ */
+ public String getMaxBloomBackfillBucketAge() {
+ return getString("maxBloomBackfillBucketAge", null);
+ }
+
+ /**
+ * Returns the maximum number of concurrent optimize processes that
+ * can run against a hot bucket for this index.
+ *
+ * @return The maximum number of concurrent optimize processes.
+ */
+ public int getMaxConcurrentOptimizes() {
+ return getInteger("maxConcurrentOptimizes");
+ }
+
+ /**
+ * Returns the maximum data size before triggering a roll from hot to warm
+ * buckets for this index.
+ *
+ * @return The maximum data size, in MB, or "auto" (which means 750MB), or
+ * "auto_high_volume" (which means 10GB on a 64-bit system, or 1GB on a
+ * 32-bit system).
+ * @see #setMaxDataSize
+ */
+ public String getMaxDataSize() {
+ return getString("maxDataSize");
+ }
+
+ /**
+ * Returns the maximum number of hot buckets that can exist for this index.
+ *
+ * @return The maximum number of hot buckets or "auto" (which means 3).
+ */
+ public String getMaxHotBuckets() {
+ return getString("maxHotBuckets");
+ }
+
+ /**
+ * Returns the maximum lifetime of a hot bucket for this index.
+ * If a hot bucket exceeds this value, Splunk rolls it to warm.
+ * A value of 0 means an infinite lifetime.
+ *
+ * @return The hot bucket's maximum lifetime, in seconds.
+ */
+ public int getMaxHotIdleSecs() {
+ return getInteger("maxHotIdleSecs");
+ }
+
+ /**
+ * Returns the upper bound of the target maximum timespan of
+ * hot and warm buckets for this index.
+ *
+ * @return The upper bound of the target maximum timespan, in seconds.
+ */
+ public int getMaxHotSpanSecs() {
+ return getInteger("maxHotSpanSecs");
+ }
+
+ /**
+ * Returns the amount of memory to allocate for buffering
+ * a single .tsidx file into memory before flushing to disk.
+ *
+ * @return The amount of memory, in MB.
+ */
+ public int getMaxMemMB() {
+ return getInteger("maxMemMB");
+ }
+
+ /**
+ * Returns the maximum number of unique lines that are allowed
+ * in a bucket's .data files for this index. A value of 0 means infinite
+ * lines.
+ *
+ * @return The maximum number of unique lines.
+ */
+ public int getMaxMetaEntries() {
+ return getInteger("maxMetaEntries");
+ }
+
+ /**
+ * Returns the maximum number of concurrent helper processes for this index.
+ *
+ * @return The maximum number of concurrent helper processes.
+ */
+ public int getMaxRunningProcessGroups() {
+ return getInteger("maxRunningProcessGroups", 0);
+ }
+
+ /**
+ * Returns the maximum time attribute for this index.
+ *
+ * @return The maximum time attribute, or {@code null} if not specified.
+ */
+ public Date getMaxTime() {
+ return getDate("maxTime", null);
+ }
+
+ /**
+ * Returns the maximum size of this index. If an index
+ * grows larger than this value, the oldest data is frozen.
+ *
+ * @return The maximum index size, in MB.
+ */
+ public int getMaxTotalDataSizeMB() {
+ return getInteger("maxTotalDataSizeMB");
+ }
+
+ /**
+ * Returns the upper limit, in seconds, for how long an event can sit in a
+ * raw slice. This value applies only when replication is enabled for this
+ * index, and is ignored otherwise.
+ * If there are any acknowledged events sharing this raw slice, the
+ * {@code MaxTimeUnreplicatedWithAcksparamater} applies instead.
+ * @see #getMaxTimeUnreplicatedWithAcks
+ * @return int value
+ */
+ public int getMaxTimeUnreplicatedNoAcks() {
+ return getInteger("maxTimeUnreplicatedNoAcks");
+ }
+
+ /**
+ * Returns the upper limit, in seconds, for how long an event can sit
+ * unacknowledged in a raw slice. This value only applies when indexer
+ * acknowledgement is enabled on forwarders and replication is enabled with
+ * clustering.
+ * @return int value
+ */
+ public int getMaxTimeUnreplicatedWithAcks() {
+ return getInteger("maxTimeUnreplicatedWithAcks");
+ }
+
+ /**
+ * Returns the maximum number of warm buckets for this index. If this
+ * value is exceeded, the warm buckets with the lowest value for their
+ * latest times are moved to cold.
+ *
+ * @return The maximum number of warm buckets.
+ */
+ public int getMaxWarmDBCount() {
+ return getInteger("maxWarmDBCount");
+ }
+
+ /**
+ * Returns the memory pool for this index.
+ *
+ * @return The memory pool, in MB or "auto".
+ */
+ public String getMemPoolMB() {
+ return getString("memPoolMB");
+ }
+
+ /**
+ * Returns the frequency at which Splunkd forces a filesystem sync while
+ * compressing journal slices for this index.
+ *
+ * A value of "disable" disables this feature completely, while a value of 0
+ * forces a file-system sync after completing compression of every journal
+ * slice.
+ *
+ * @return The file-system sync frequency, as an integer or "disable".
+ */
+ public String getMinRawFileSyncSecs() {
+ return getString("minRawFileSyncSecs");
+ }
+
+ /**
+ * Returns the minimum time attribute for this index.
+ *
+ * @return The minimum time attribute, or {@code null} if not specified.
+ */
+ public Date getMinTime() {
+ return getDate("minTime", null);
+ }
+
+ /**
+ * Returns the number of hot buckets that were created for this index.
+ *
+ * @return The number of hot buckets.
+ */
+ public int getNumHotBuckets() {
+ return getInteger("numHotBuckets", 0);
+ }
+
+ /**
+ * Returns the number of warm buckets created for this index.
+ *
+ * @return The number of warm buckets.
+ */
+ public int getNumWarmBuckets() {
+ return getInteger("numWarmBuckets", 0);
+ }
+
+ /**
+ * Returns the number of bloom filters created for this index.
+ *
+ * @return The number of bloom filters.
+ */
+ public int getNumBloomfilters() {
+ return getInteger("numBloomfilters", 0);
+ }
+
+ /**
+ * Returns the frequency at which metadata is for partially synced (synced
+ * in-place) for this index. A value of 0 disables partial syncing, so
+ * metadata is only synced on the {@code ServiceMetaPeriod} interval.
+ * @see #getServiceMetaPeriod
+ * @see #setServiceMetaPeriod
+ *
+ * @return The metadata sync interval, in seconds.
+ */
+ public int getPartialServiceMetaPeriod() {
+ return getInteger("partialServiceMetaPeriod");
+ }
+
+ /**
+ * Returns the future event-time quarantine for this index. Events
+ * that are newer than now plus this value are quarantined.
+ *
+ * @return The future event-time quarantine, in seconds.
+ */
+ public int getQuarantineFutureSecs() {
+ return getInteger("quarantineFutureSecs");
+ }
+
+ /**
+ * Returns the past event-time quarantine for this index. Events
+ * that are older than now minus this value are quarantined.
+ *
+ * @return The past event-time quarantine, in seconds.
+ */
+ public int getQuarantinePastSecs() {
+ return getInteger("quarantinePastSecs");
+ }
+
+ /**
+ * Returns the target uncompressed size of individual raw slices in the
+ * rawdata journal for this index.
+ *
+ * @return The target uncompressed size, in bytes.
+ */
+ public int getRawChunkSizeBytes() {
+ return getInteger("rawChunkSizeBytes");
+ }
+
+ /**
+ * Returns the frequency to check for the need to create a new hot bucket
+ * and the need to roll or freeze any warm or cold buckets for this index.
+ *
+ * @return The check frequency, in seconds.
+ */
+ public int getRotatePeriodInSecs() {
+ return getInteger("rotatePeriodInSecs");
+ }
+
+ /**
+ * Returns the frequency at which metadata is synced to disk for this index.
+ *
+ * @return The meta data sync frequency, in seconds.
+ */
+ public int getServiceMetaPeriod() {
+ return getInteger("serviceMetaPeriod");
+ }
+
+ /**
+ * Returns a list of indexes that suppress "index missing" messages.
+ *
+ * @return A comma-separated list of indexes.
+ */
+ public String getSuppressBannerList() {
+ return getString("suppressBannerList", null);
+ }
+
+ /**
+ * Returns the number of events that trigger the indexer to sync events.
+ * This value is global, not a per-index value.
+ *
+ * @return The number of events that trigger the indexer to sync events.
+ */
+ public int getSync() {
+ return getInteger("sync");
+ }
+
+ /**
+ * Indicates whether the sync operation is called before the file
+ * descriptor is closed on metadata updates.
+ *
+ * @return {@code true} if the sync operation is called before the file
+ * descriptor is closed on metadata updates, {@code false} if not.
+ */
+ public boolean getSyncMeta() {
+ return getBoolean("syncMeta");
+ }
+
+ /**
+ * Returns the absolute path to the thawed index for this index. This value
+ * may contain shell expansion terms.
+ *
+ * @return The absolute path to the thawed index, or {@code null} if not
+ * specified.
+ */
+ public String getThawedPath() {
+ return getString("thawedPath", null);
+ }
+
+ /**
+ * Returns the expanded absolute path to the thawed index for this index.
+ *
+ * @return The expanded absolute path to the thawed index, or {@code null}
+ * if not specified.
+ */
+ public String getThawedPathExpanded() {
+ return getString("thawedPath_expanded", null);
+ }
+
+ /**
+ * Returns the frequency at which Splunk checks for an index throttling
+ * condition.
+ *
+ * @return The frequency of the throttling check, in seconds.
+ */
+ public int getThrottleCheckPeriod() {
+ return getInteger("throttleCheckPeriod");
+ }
+
+ /**
+ * Returns the total event count for this index.
+ *
+ * @return The total event count.
+ */
+ public int getTotalEventCount() {
+ return getInteger("totalEventCount");
+ }
+
+ /**
+ * Indicates whether this index is an internal index.
+ *
+ * @return {@code true} if this index is an internal index, {@code false}
+ * if not.
+ */
+ public boolean isInternal() {
+ return getBoolean("isInternal");
+ }
+
+ /**
+ * Performs rolling hot buckets for this index.
+ */
+ public void rollHotBuckets() {
+ ResponseMessage response = service.post(path + "/roll-hot-buckets");
+ assert(response.getStatus() == 200);
+ }
+
+ /**
+ * Sets whether the data retrieved from this index is UTF8-encoded.
+ *
+ * Note: Indexing performance degrades when this parameter is set to
+ * {@code true}.
+ *
+ * In Splunk 5.0 and later, this is a global property and cannot be set on
+ * a per-index basis.
+ *
+ * @param assure {@code true} to ensure UTF8 encoding, {@code false} if not.
+ */
+ public void setAssureUTF8(boolean assure) {
+ setCacheValue("assureUTF8", assure);
+ }
+
+ /**
+ * Sets the number of events that make up a block for block signatures. A
+ * value of 100 is recommended. A value of 0 disables block signing for this
+ * index.
+ *
+ * @param value The event count for block signing.
+ */
+ public void setBlockSignSize(int value) {
+ setCacheValue("blockSignSize", value);
+ }
+
+
+ /**
+ * Sets the suggested size of the .tsidx file for the bucket rebuild
+ * process.
+ *
+ * Valid values are: "auto", a positive integer, or a positive
+ * integer followed by "KB", "MB", or "GB".
+ *
+ * @param value The suggested size of the .tsidx file for the bucket rebuild
+ * process.
+ */
+ public void setBucketRebuildMemoryHint(String value) {
+ setCacheValue("bucketRebuildMemoryHint", value);
+ }
+
+ /**
+ * Sets the destination path for the frozen archive, where Splunk
+ * automatically puts frozen buckets. The bucket freezing policy is as
+ * follows:
+ *
New-style buckets (4.2 and later): All files are removed
+ * except the raw data. To thaw frozen buckets, run {@code Splunk rebuild
+ * } on the bucket, then move the buckets to the thawed
+ * directory.
+ *
Old-style buckets (4.1 and earlier): gzip all the .data and
+ * .tsidx files. To thaw frozen buckets, gunzip the zipped files and move
+ * the buckets to the thawed directory.
+ * If both {@code coldToFrozenDir} and {@code coldToFrozenScript} are
+ * specified, {@code coldToFrozenDir} takes precedence.
+ * @see #setColdToFrozenScript
+ * @see #getColdToFrozenScript
+ *
+ * @param destination The destination path for the frozen archive.
+ */
+ public void setColdToFrozenDir(String destination) {
+ setCacheValue("coldToFrozenDir", destination);
+ }
+
+ /**
+ * Sets the path to the archiving script.
+ *
For more info about archiving scripts, see the
+ * POST data/indexes endpoint in the REST API
+ * documentation.
+ * @see #setColdToFrozenDir
+ * @see #getColdToFrozenDir
+ *
+ * @param script The path to the archiving script.
+ */
+ public void setColdToFrozenScript(String script) {
+ setCacheValue("coldToFrozenScript", script);
+ }
+
+ /**
+ * Sets whether asynchronous "online fsck" bucket repair is enabled.
+ *
+ * When this feature is enabled, you don't have to wait for buckets to be
+ * repaired before starting Splunk, but you might notice a slight
+ * degradation in performance as a result.
+ *
+ * @param value {@code true} to enable online bucket repair, {@code false}
+ * if not.
+ */
+ public void setEnableOnlineBucketRepair(boolean value) {
+ setCacheValue("enableOnlineBucketRepair", value);
+ }
+
+ /**
+ * Sets the maximum age for a bucket, after which the data in this index
+ * rolls to frozen. Freezing data removes it from the index. To archive
+ * data, see {@code coldToFrozenDir} and {@code coldToFrozenScript}.
+ * @see #setColdToFrozenDir
+ * @see #setColdToFrozenScript
+ *
+ * @param seconds The time, in seconds, after which indexed data rolls to
+ * frozen.
+ */
+ public void setFrozenTimePeriodInSecs(int seconds) {
+ setCacheValue("frozenTimePeriodInSecs", seconds);
+ }
+
+ /**
+ * Sets the time that indicates a bucket age. When a warm or cold bucket
+ * is older than this, Splunk does not create or rebuild its bloomfilter.
+ * The valid format is number followed by a time unit ("s", "m", "h",
+ * or "d"). For example, "30d" for 30 days.
+ * @param time The time that indicates a bucket age.
+ */
+ public void setMaxBloomBackfillBucketAge(String time) {
+ setCacheValue("maxBloomBackfillBucketAge", time);
+ }
+
+ /**
+ * Sets the number of concurrent optimize processes that can run against
+ * a hot bucket for this index.
+ *
+ * @param processes The number of concurrent optimize processes.
+ */
+ public void setMaxConcurrentOptimizes(int processes) {
+ setCacheValue("maxConcurrentOptimizes", processes);
+ }
+
+ /**
+ * Sets the maximum data size before triggering a roll from hot to warm
+ * buckets for this index. You can also specify a value to let Splunk
+ * autotune this parameter: use "auto_high_volume" for high-volume indexes
+ * (such as the main index, or one that gets over 10GB of data per day);
+ * otherwise, use "auto".
+ * @see #getMaxDataSize
+ *
+ * @param size The size in MB, or an autotune string.
+ */
+ public void setMaxDataSize(String size) {
+ setCacheValue("maxDataSize", size);
+ }
+
+ /**
+ * Sets the maximum number of hot buckets that can exist per index.
+ *
+ * When {@code maxHotBuckets} is exceeded, Splunk rolls the least recently
+ * used (LRU) hot bucket to warm. Both normal hot buckets and quarantined
+ * hot buckets count towards this total. This setting operates independently
+ * of {@code MaxHotIdleSecs}, which can also cause hot buckets to roll.
+ * @see #setMaxHotIdleSecs
+ * @see #getMaxHotIdleSecs
+ *
+ * @param size The maximum number of hot buckets per index, or an 'auto' string.
+ */
+ public void setMaxHotBuckets(String size) {
+ setCacheValue("maxHotBuckets", size);
+ }
+
+ /**
+ * Sets the maximum lifetime of a hot bucket for this index.
+ *
+ * If a hot bucket exceeds this value, Splunk rolls it to warm.
+ * This setting operates independently of {@code MaxHotBuckets}, which can
+ * also cause hot buckets to roll.
+ * @see #setMaxHotBuckets
+ * @see #getMaxHotBuckets
+ *
+ * @param seconds The hot bucket's maximum lifetime, in seconds. A value of
+ * 0 means an infinite lifetime.
+ */
+ public void setMaxHotIdleSecs(int seconds) {
+ setCacheValue("maxHotIdleSecs", seconds);
+ }
+
+ /**
+ * Sets the upper bound of the target maximum timespan of hot and warm
+ * buckets for this index.
+ *
+ * Note: If you set this too small, you can get an explosion of
+ * hot and warm buckets in the file system. The system sets a lower bound
+ * implicitly for this parameter at 3600, but this advanced parameter should
+ * be set with care and understanding of the characteristics of your data.
+ *
+ * @param seconds The upper bound of the target maximum timespan, in
+ * seconds.
+ */
+ public void setMaxHotSpanSecs(int seconds) {
+ setCacheValue("maxHotSpanSecs", seconds);
+ }
+
+ /**
+ * Sets the amount of memory allocated for buffering a single .tsidx
+ * file before flushing to disk.
+ *
+ * @param memory The amount of memory, in MB.
+ */
+ public void setMaxMemMB(int memory) {
+ setCacheValue("maxMemMB", memory);
+ }
+
+ /**
+ * Sets the maximum number of unique lines in .data files in a bucket, which
+ * may help to reduce memory consumption.
+ *
+ * If this value is exceeded, a hot bucket is rolled to prevent a further
+ * increase. If your buckets are rolling due to Strings.data hitting this
+ * limit, the culprit might be the "punct" field in your data. If you don't
+ * use that field, it might be better to just disable this (see the
+ * props.conf.spec in $SPLUNK_HOME/etc/system/README).
+ *
+ * @param entries The maximum number of unique lines. A value of 0 means
+ * infinite lines.
+ */
+ public void setMaxMetaEntries(int entries) {
+ setCacheValue("maxMetaEntries", entries);
+ }
+
+
+ /**
+ * Sets the upper limit for how long an event can sit in a
+ * raw slice. This value applies only when replication is enabled for this
+ * index, and is ignored otherwise.
+ * If there are any acknowledged events sharing this raw slice, the
+ * {@code MaxTimeUnreplicatedWithAcksparamater} applies instead.
+ *
+ * @param value The upper limit, in seconds. A value of 0 disables this
+ * setting.
+ */
+ public void setMaxTimeUnreplicatedNoAcks(int value) {
+ setCacheValue("maxTimeUnreplicatedNoAcks", value);
+ }
+
+ /**
+ * Sets the upper limit for how long an event can sit unacknowledged in a
+ * raw slice. This value only applies when indexer acknowledgement is
+ * enabled on forwarders and replication is enabled with clustering.
+ *
+ * This number should not exceed the acknowledgement timeout configured on
+ * any forwarder.
+ *
+ * @param value The upper limit, in seconds. A value of 0 disables this
+ * setting (not recommended).
+ */
+ public void setMaxTimeUnreplicatedWithAcks(int value) {
+ setCacheValue("maxTimeUnreplicatedWithAcks", value);
+ }
+
+ /**
+ * Sets the maximum size for this index. If an index grows larger than this
+ * value, the oldest data is frozen.
+ *
+ * @param size The maximum index size, in MB.
+ */
+ public void setMaxTotalDataSizeMB(int size) {
+ setCacheValue("maxTotalDataSizeMB", size);
+ }
+
+ /**
+ * Sets the maximum number of warm buckets. If this number is exceeded,
+ * the warm buckets with the lowest value for their latest times will be
+ * moved to cold.
+ *
+ * @param buckets The maximum number of warm buckets.
+ */
+ public void setMaxWarmDBCount(int buckets) {
+ setCacheValue("maxWarmDBCount", buckets);
+ }
+
+ /**
+ * Sets the frequency at which Splunkd forces a file system sync while
+ * compressing journal slices for this index. A value of "disable" disables
+ * this feature completely, while a value of 0 forces a file-system sync
+ * after completing compression of every journal slice.
+ *
+ * @param frequency The file-system sync frequency, as an integer or
+ * "disable".
+ */
+ public void setMinRawFileSyncSecs(String frequency) {
+ setCacheValue("minRawFileSyncSecs", frequency);
+ }
+
+ /**
+ * Sets the frequency at which metadata is for partially synced (synced
+ * in-place) for this index. A value of 0 disables partial syncing, so
+ * metadata is only synced on the {@code ServiceMetaPeriod} interval.
+ * @see #setServiceMetaPeriod
+ * @see #getServiceMetaPeriod
+ *
+ * @param frequency The metadata sync interval, in seconds.
+ */
+ public void setPartialServiceMetaPeriod(int frequency) {
+ setCacheValue("partialServiceMetaPeriod", frequency);
+ }
+
+ /**
+ * Sets a quarantine for events that are timestamped in the future to help
+ * prevent main hot buckets from being polluted with fringe events. Events
+ * that are newer than "now" plus this value are quarantined.
+ *
+ * @param window The future event-time quarantine, in seconds.
+ */
+ public void setQuarantineFutureSecs(int window) {
+ setCacheValue("quarantineFutureSecs", window);
+ }
+
+ /**
+ * Sets a quarantine for events that are timestamped in the past to help
+ * prevent main hot buckets from being polluted with fringe events. Events
+ * that are older than "now" plus this value are quarantined.
+ *
+ * @param window The past event-time quarantine, in seconds.
+ */
+ public void setQuarantinePastSecs(int window) {
+ setCacheValue("quarantinePastSecs", window);
+ }
+
+ /**
+ * Sets the target uncompressed size of individual raw slices in the rawdata
+ * journal for this index.
+ *
+ * This parameter only specifies a target chunk size. The actual chunk size
+ * might be slightly larger by an amount proportional to an individual event
+ * size.
+ *
+ * WARNING: This is an advanced parameter. Only change it if you are
+ * instructed to do so by Splunk Support.
+ *
+ * @param size The target uncompressed size, in bytes. (0 is not a valid
+ * value--if 0 is used, this parameter is set to the default value.)
+ */
+ public void setRawChunkSizeBytes(int size) {
+ setCacheValue("rawChunkSizeBytes", size);
+ }
+
+ /**
+ * Sets the frequency to check for the need to create a new hot bucket and
+ * the need to roll or freeze any warm or cold buckets for this index.
+ *
+ * @param frequency The check frequency, in seconds.
+ */
+ public void setRotatePeriodInSecs(int frequency) {
+ setCacheValue("rotatePeriodInSecs", frequency);
+ }
+
+ /**
+ * Sets the frequency at which metadata is synced to disk for this index.
+ *
+ * @param frequency The meta data sync frequency, in seconds.
+ */
+ public void setServiceMetaPeriod(int frequency) {
+ setCacheValue("serviceMetaPeriod", frequency);
+ }
+
+ /**
+ * Sets whether the sync operation is called before the file descriptor is
+ * closed on metadata updates.
+ *
+ * This functionality improves the integrity of metadata files, especially
+ * with regard to operating system crashes and machine failures.
+ *
+ * WARNING: This is an advanced parameter. Only change it if you are
+ * instructed to do so by Splunk Support.
+ *
+ * @param sync {@code true} to call the sync operation before the file
+ * descriptor is closed on metadata updates, {@code false} if not.
+ */
+ public void setSyncMeta(boolean sync) {
+ setCacheValue("syncMeta", sync);
+ }
+
+ /**
+ * Sets the frequency at which Splunk checks for an index throttling
+ * condition.
+ *
+ * @param frequency The frequency of the throttling check, in seconds.
+ */
+ public void setThrottleCheckPeriod(int frequency) {
+ setCacheValue("throttleCheckPeriod", frequency);
+ }
+
+ /**
+ * Submits an event to this index through an HTTP POST request.
+ *
+ * @param data The event data to post.
+ */
+ public void submit(String data) {
+ Receiver receiver = service.getReceiver();
+ receiver.submit(getName(), data);
+ }
+
+ /**
+ * Submits an event to this index through an HTTP POST request.
+ *
+ * @param args Optional arguments for this request. Valid parameters are:
+ * "host", "host_regex", "source", and "sourcetype".
+ * @param data The event data to post.
+ */
+ public void submit(Args args, String data) {
+ Receiver receiver = service.getReceiver();
+ receiver.submit(getName(), args, data);
+ }
+
+ /**
+ * Uploads a file to this index as an event stream.
+ *
+ * Note: This file must be directly accessible by the Splunk server.
+ *
+ * @param filename The path and filename.
+ */
+ public void upload(String filename) {
+ EntityCollection uploads = service.getUploads();
+ Args args = new Args("index", getName());
+ uploads.create(filename, args);
+ }
+
+ /**
+ * Uploads a file to this index as an event stream.
+ *
+ * Note: 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 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);
+ }
+}
+
diff --git a/splunk/src/main/java/com/splunk/IndexCollection.java b/splunk/src/main/java/com/splunk/IndexCollection.java
new file mode 100644
index 00000000..cf98d95a
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/IndexCollection.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+/**
+ * The {@code IndexCollection} class represents a collection of indexes.
+ */
+public class IndexCollection extends EntityCollection {
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ IndexCollection(Service service) {
+ super(service, "data/indexes", Index.class);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them (see {@link IndexCollectionArgs}).
+ */
+ IndexCollection(Service service, Args args) {
+ super(service, "data/indexes", Index.class, args);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Index remove(String key) {
+ if (this.service.versionCompare("5.0") < 0) {
+ throw new UnsupportedOperationException(
+ "Indexes cannot be deleted via the REST API in versions " +
+ "prior to 5.0");
+ } else {
+ return (Index)super.remove(key);
+ }
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/IndexCollectionArgs.java b/splunk/src/main/java/com/splunk/IndexCollectionArgs.java
new file mode 100644
index 00000000..0b60d5c1
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/IndexCollectionArgs.java
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+/**
+ * The {@code IndexCollectionArgs} class contains arguments for retrieving
+ * indexes from a collection (see {@link Service#getIndexes}).
+ */
+public class IndexCollectionArgs extends CollectionArgs {
+
+ /**
+ * Class constructor.
+ */
+ public IndexCollectionArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the maximum number of entries to return.
+ *
+ * @param count
+ * The maximum number of entries to return. To return all entries, specify -1.
+ */
+ public void setCount(int count) {
+ super.setCount(count);
+ }
+
+ /**
+ * Sets whether to omits certain index details to provide a faster response.
+ *
+ * @param summarize
+ * {@code true} to omit index details for a faster response,
+ * {@code false} if not.
+ */
+ public void setSummarize(boolean summarize) {
+ this.put("summarize", summarize);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/Input.java b/splunk/src/main/java/com/splunk/Input.java
new file mode 100644
index 00000000..95ca6c8d
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/Input.java
@@ -0,0 +1,56 @@
+/*
+ * 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.Map;
+
+/**
+ * The {@code Input} class represents a data input. This class is the base for
+ * all typed {@code Input} classes and is also used when Splunk does not
+ * recognize an input kind.
+ */
+public class Input extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The input endpoint.
+ */
+ Input(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns an {@code InputKind} representing this input's type.
+ *
+ * The input kind is inferred from the input's path.
+ * @return InputKind instance
+ */
+ public InputKind getKind() {
+ String[] pathComponents =
+ Util.substringAfter(this.path, "/data/inputs/", null).split("/");
+
+ String kindPath;
+ if (pathComponents[0].equals("tcp")) {
+ kindPath = "tcp/" + pathComponents[1];
+ } else {
+ kindPath = pathComponents[0];
+ }
+ return InputKind.create(kindPath);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/InputCollection.java b/splunk/src/main/java/com/splunk/InputCollection.java
new file mode 100644
index 00000000..0fcefa02
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/InputCollection.java
@@ -0,0 +1,407 @@
+/*
+ * 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.*;
+
+/**
+ * The {@code InputCollection} class represents a collection of inputs. The
+ * collection is heterogeneous and each member contains an {@code InputKind}
+ * value that indicates the specific type of input.
+ */
+public class InputCollection extends EntityCollection {
+ protected Set inputKinds = new HashSet();
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ InputCollection(Service service) {
+ super(service, "data/inputs");
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them. See {@link CollectionArgs}.
+ */
+ InputCollection(Service service, Args args) {
+ super(service, "data/inputs", args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean containsKey(Object key) {
+ Input input = retrieveInput((String)key);
+ return (input != null);
+ }
+
+ /**
+ * Creates a stub for a new data input.
+ *
+ * @param name Depending on the type of input, a string that contains:
+ *
The filename or directory and path (for monitor and oneshot
+ * inputs)
+ *
The script name (for script inputs)
+ *
The port number (for TCP and UDP inputs)
+ *
The collection name (for Windows Perfmon and WMI inputs)
+ *
The stanza (for Windows Registry inputs)
+ *
The name of the configuration (for Windows AD inputs)
+ * @return No return value.
+ * @throws UnsupportedOperationException The UnsupportedOperationException instance
+ */
+ @Override public Input create(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Creates a stub for a new data input based on additional arguments.
+ *
+ * @param name Depending on the type of data input, a string that contains:
+ *
The filename or directory and path (for monitor and oneshot
+ * inputs)
+ *
The script name (for script inputs)
+ *
The port number (for TCP and UDP inputs)
+ *
The collection name (for Windows Perfmon and WMI inputs)
+ *
The stanza (for Windows Registry inputs)
+ *
The name of the configuration (for Windows AD inputs)
+ * @param args Optional arguments to define the data input. For a list of
+ * the available parameters, see
+ * Input parameters on
+ * dev.splunk.com.
+ * @return No return value.
+ * @throws UnsupportedOperationException The UnsupportedOperationException instance
+ */
+ @Override public Input create(String name, Map args) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Creates a new data input based on the input kind.
+ *
+ * @param name Depending on the type of data input, a string that contains:
+ *
The filename or directory and path (for monitor and oneshot
+ * inputs)
+ *
The script name (for script inputs)
+ *
The port number (for TCP and UDP inputs)
+ *
The collection name (for Windows Perfmon and WMI inputs)
+ *
The stanza (for Windows Registry inputs)
+ *
The name of the configuration (for Windows AD inputs)
+ * @param kind A member of {@code InputKind}, indicating the type of input.
+ * @param The implicit type of the input.
+ * @return The {@code Input} that was created.
+ */
+ public T create(String name, InputKind kind) {
+ return (T)create(name, kind, (Map)null);
+ }
+
+ /**
+ * Creates a new data input based on the input kind and additional
+ * arguments.
+ *
+ * @param name Depending on the type of data input, a string that contains:
+ *
The filename or directory and path (for monitor and oneshot
+ * inputs)
+ *
The script name (for script inputs)
+ *
The port number (for TCP and UDP inputs)
+ *
The collection name (for Windows Perfmon and WMI inputs)
+ *
The stanza (for Windows Registry inputs)
+ *
The name of the configuration (for Windows AD inputs)
+ * @param kind A member of {@code InputKind}, indicating the type of input.
+ * @param args Optional arguments to define the data input. For a list of
+ * the available parameters, see
+ * Input parameters on
+ * dev.splunk.com.
+ * @param The implicit type of the input.
+ * @return The {@code Input} that was created.
+ */
+ public T
+ create(String name, InputKind kind, Map args) {
+ args = Args.create(args).add("name", name);
+ String path = this.path + "/" + kind.getRelativePath();
+ service.post(path, args);
+
+ invalidate();
+
+ return (T)get(name);
+ }
+
+ /**
+ * Creates a new data input based on an Atom entry.
+ *
+ * @param entry The {@code AtomEntry} object describing the entry.
+ * @return The {@code Input} that was created.
+ */
+ @Override
+ protected Input createItem(AtomEntry entry) {
+ String path = itemPath(entry);
+ InputKind kind = itemKind(path);
+ Class inputClass = kind.getInputClass();
+ return createItem(inputClass, path, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Input get(Object key) {
+ return retrieveInput((String)key);
+ }
+
+ /**
+ * Returns the value of a scoped, namespace-constrained key, if it
+ * exists within this collection.
+ *
+ * @param key The key to look up.
+ * @param namespace The namespace to constrain the search to.
+ * @return The value indexed by the key, or {@code null} if it doesn't
+ * exist.
+ */
+ public Input get(Object key, Args namespace) {
+ Util.ensureNamespaceIsExact(namespace);
+ return retrieveInput((String)key, namespace);
+ }
+
+ /**
+ * Returns the input kind for a given path.
+ *
+ * @param path The relative endpoint path (the path that follows
+ * data/inputs).
+ * @return A member of {@code InputKind}, indicating the type of input.
+ */
+ protected InputKind itemKind(String path) {
+ String relpathWithInputName = Util.substringAfter(path, "/data/inputs/", null);
+ for (InputKind kind : inputKinds) {
+ if (relpathWithInputName.startsWith(kind.getRelativePath())) {
+ return kind;
+ }
+ }
+
+ // Not good. This means that there is an input of an unknown kind.
+ return InputKind.Unknown;
+ }
+
+ /**
+ * Return a set of all the input kinds recognized by the Splunk server.
+ *
+ * @return A set of {@code InputKind}s.
+ */
+ public Set getInputKinds() {
+ return this.inputKinds;
+ }
+
+ /**
+ * Indicates whether a given string matches the input name (string
+ * equality). For scripted inputs, which are listed by their full path, this
+ * method compares only the final component of the filename for a match.
+ *
+ * @param kind A member of {@code InputKind}, indicating the type of input.
+ * @param searchFor A string to search for.
+ * @param searchIn The string that contains the input name.
+ * @return {@code true} if the string matches the input name, {@code false}
+ * if not.
+ */
+ protected static boolean matchesInputName(InputKind kind, String searchFor, String searchIn) {
+ if (kind == InputKind.Script) {
+ return searchIn.endsWith("/" + searchFor) || searchIn.endsWith("\\" + searchFor);
+ } else {
+ return searchFor.equals(searchIn);
+ }
+ }
+
+
+ /**
+ * Assembles a set of all the input kinds that are available on this Splunk
+ * instance. To list all inputs, pass an empty list to {@code subPath}. Or,
+ * specify a component of the path such as "tcp" to list all TCP inputs.
+ *
+ * @param subPath A list of strings containing the components of the
+ * endpoint path that follow data/inputs/.
+ * @return A set of available {@code InputKind}s.
+ */
+ private Set assembleInputKindSet(List subPath) {
+ Set kinds = new HashSet();
+ ResponseMessage response = service.get(this.path + "/" + Util.join("/", subPath));
+ AtomFeed feed = AtomFeed.parseStream(response.getContent());
+ for (AtomEntry entry : feed.entries) {
+ String itemKeyName = itemKey(entry);
+
+ boolean hasCreateLink = false;
+ for (String linkName : entry.links.keySet()) {
+ if (linkName.equals("create")) {
+ hasCreateLink = true;
+ }
+ }
+
+ List thisSubPath = new ArrayList(subPath);
+ thisSubPath.add(itemKeyName);
+
+ String relpath = Util.join("/", thisSubPath);
+
+ if (relpath.equals("all") || relpath.equals("tcp/ssl")) {
+ // Skip these input types
+ continue;
+ } else if (hasCreateLink) {
+ // Found an InputKind leaf
+ InputKind newKind = InputKind.create(relpath);
+ kinds.add(newKind);
+ } else {
+ Set subKinds = assembleInputKindSet(thisSubPath);
+ kinds.addAll(subKinds);
+ }
+ }
+ return kinds;
+ }
+
+ /**
+ * Refreshes the {@code inputKinds} field on this object.
+ */
+ private void refreshInputKinds() {
+ Set kinds = assembleInputKindSet(new ArrayList());
+
+ this.inputKinds.clear();
+ this.inputKinds.addAll(kinds);
+ }
+
+ /**
+ * Refreshes this input collection.
+ *
+ * @return The refreshed {@code InputCollection}.
+ */
+ @Override public InputCollection refresh() {
+ // Populate this.inputKinds
+ refreshInputKinds();
+
+ items.clear();
+
+ // Iterate over all input kinds and collect all instances.
+ for (InputKind kind : this.inputKinds) {
+ if (service.versionIsAtLeast("6.0.0")) {
+ // In Splunk 6 and later, the registry endpoint has been deprecated in favor of the new
+ // WinRegMon modular input, but both now point to the same place. To avoid duplicates, we have
+ // to read only one of them.
+ if (kind.getKind().equals("registry")) {
+ continue;
+ }
+ }
+ String relpath = kind.getRelativePath();
+ String inputs = String.format("%s/%s?count=-1", path, relpath);
+ ResponseMessage response;
+ try {
+ response = service.get(inputs);
+ }
+ catch (HttpException e) {
+ // On some platforms certain input endpoints don't exist, for
+ // example the Windows inputs endpoints don't exist on non-
+ // Windows platforms.
+ if (e.getStatus() == 404) continue;
+ throw e;
+ }
+ AtomFeed feed;
+ try {
+ feed = AtomFeed.parseStream(response.getContent());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ load(feed);
+ }
+
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Input remove(String key) {
+ Input input = retrieveInput(key);
+ if (input != null) {
+ input.remove();
+ }
+ return input;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Input remove(
+ String key, Args namespace) {
+ Util.ensureNamespaceIsExact(namespace);
+
+ Input input = retrieveInput(key, namespace);
+ if (input != null) {
+ input.remove();
+ }
+ return input;
+ }
+
+ private Input retrieveInput(String key) {
+ validate();
+
+ // Because scripted input names are not 1:1 with the original name
+ // (they are the absolute path on the Splunk instance followed by
+ // the original name), we will iterate over the entities in the list,
+ // and if we find one that matches, return it.
+ Set>> set = items.entrySet();
+ for (Entry> entry: set) {
+ String entryKey = entry.getKey();
+ LinkedList entryValue = entry.getValue();
+ InputKind kind = entryValue.get(0).getKind();
+
+ if (InputCollection.matchesInputName(kind, key, entryKey)) {
+ if (entryValue.size() > 1) {
+ throw new SplunkException(SplunkException.AMBIGUOUS,
+ "Multiple inputs matched " + key + "; specify a namespace to disambiguate.");
+ } else {
+ return entryValue.get(0);
+ }
+ }
+ }
+ return null;
+ }
+
+ private Input retrieveInput(String key, Args namespace) {
+ Util.ensureNamespaceIsExact(namespace);
+ validate();
+
+ // Because scripted input names are not 1:1 with the original name
+ // (they are the absolute path on the Splunk instance followed by
+ // the original name), we will iterate over the entities in the list,
+ // and if we find one that matches, return it.
+ String pathMatcher = service.fullpath("", namespace);
+ Set>> set = items.entrySet();
+ for (Entry> entry: set) {
+ String entryKey = entry.getKey();
+ LinkedList entryValue = entry.getValue();
+ InputKind kind = entryValue.get(0).getKind();
+
+ if (InputCollection.matchesInputName(kind, key, entryKey)) {
+ for (Input entity: entryValue) {
+ if (entity.path.startsWith(pathMatcher)) {
+ return entity;
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
+
diff --git a/splunk/src/main/java/com/splunk/InputKind.java b/splunk/src/main/java/com/splunk/InputKind.java
new file mode 100644
index 00000000..f3cd62b3
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/InputKind.java
@@ -0,0 +1,136 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+/**
+ * The {@code InputKind} enumeration defines the different types of Splunk data
+ * inputs (input kinds). For example, a raw TCP input is
+ * {@code InputKind.Tcp}, and a cooked TCP input is {@code InputKind.TcpSplunk}.
+ * Each modular input kind shows up as a separate instance of {@code InputKind}.
+ */
+public class InputKind {
+ private String kind;
+ private String relpath;
+ private Class extends Input> inputClass;
+
+ private static Map knownRelpaths = new HashMap();
+
+ /** Unknown type of input. */
+ public static final InputKind Unknown = new InputKind(null, Input.class, "unknown");
+
+ /** Monitor input. */
+ public static final InputKind Monitor = new InputKind("monitor", MonitorInput.class);
+
+ /** Script input. */
+ public static final InputKind Script = new InputKind("script", ScriptInput.class);
+
+ /** Raw TCP input. */
+ public static final InputKind Tcp = new InputKind("tcp/raw", TcpInput.class, "tcp");
+
+ /** Cooked TCP input. */
+ public static final InputKind TcpSplunk = new InputKind("tcp/cooked", TcpSplunkInput.class);
+
+ /** UDP input. */
+ public static final InputKind Udp = new InputKind("udp", UdpInput.class);
+
+ /** Windows Active Directory input. */
+ public static final InputKind WindowsActiveDirectory = new InputKind("ad", WindowsActiveDirectoryInput.class);
+
+ /** Windows event log input. */
+ public static final InputKind WindowsEventLog = new InputKind("win-event-log-collections",WindowsEventLogInput.class);
+ // As of Splunk 6, "win-event-log-collections" has changed to "WinEventLog".
+ public static final InputKind WinEventLog = new InputKind("WinEventLog", WindowsEventLogInput.class);
+
+ /** Windows performance monitor input. */
+ public static final InputKind WindowsPerfmon = new InputKind("win-perfmon", WindowsPerfmonInput.class);
+
+ /** Windows Registry input. */
+ public static final InputKind WindowsRegistry = new InputKind("registry", WindowsRegistryInput.class);
+ // As of Splunk 6, "registry" has changed to "WinRegMon".
+ public static final InputKind WinRegMon = new InputKind("WinRegMon", WindowsRegistryInput.class);
+
+ /** Windows Management Instrumentation (WMI) input. */
+ public static final InputKind WindowsWmi = new InputKind("win-wmi-collections", WindowsWmiInput.class);
+
+ private InputKind(String relpath, Class extends Input> inputClass, String kind) {
+ this.relpath = relpath;
+ this.inputClass = inputClass;
+ this.kind = kind;
+
+ knownRelpaths.put(relpath, this);
+ }
+
+ private InputKind(String relpath, Class extends Input> inputClass) {
+ this(
+ relpath,
+ inputClass,
+ relpath
+ );
+ }
+
+ /**
+ * @return A string that specifies the input kind, as it is
+ * represented in the Atom entry for an input entity.
+ */
+ String getKind() {
+ return kind;
+ }
+
+ /**
+ * @return A string that contains the relative endpoint path from the
+ * data/inputs/ endpoint to this input kind.
+ */
+ String getRelativePath() {
+ return relpath;
+ }
+
+ /**
+ * @return The class to use to create instances for this input kind.
+ */
+ Class extends Input> getInputClass() {
+ return inputClass;
+ }
+
+ /**
+ * Create an {@code InputKind} object from a {@code String} giving
+ * the relative path from data/inputs/ to the kind. For example,
+ * "tcp/raw" or "monitor".
+ *
+ * {@code InputKind}'s constructors are private. You should use this method
+ * to create an {@code InputKind}.
+ *
+ * @param relpath The relative path from data/inputs specifying the {@code InputKind} to create.
+ * @return An {@code InputKind} object.
+ */
+ public static InputKind create(String relpath) {
+ if (knownRelpaths.containsKey(relpath)) {
+ return knownRelpaths.get(relpath);
+ } else {
+ return new InputKind(relpath, Input.class);
+ }
+ }
+
+ /**
+ * @return Textual representation for debugging purposes.
+ */
+ public String toString() {
+ return relpath;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/InsertRootElementFilterInputStream.java b/splunk/src/main/java/com/splunk/InsertRootElementFilterInputStream.java
new file mode 100644
index 00000000..b668f850
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/InsertRootElementFilterInputStream.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2014 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.*;
+
+/**
+ * Takes an InputStream containing a UTF-8 encoded XML document containing one or more
+ * root 'results' elements, and wraps a 'doc' element around
+ * all of them so normal XML parsers can handle the stream. Multiple root 'results'
+ * elements occur when getting results from an export search.
+ *
+ * It works by finding the first instance of '' before it, and then returning '' after the end of the stream
+ * it is filtering.
+ */
+class InsertRootElementFilterInputStream extends FilterInputStream {
+ private static final int REREAD_BUFFER_SIZE = 512;
+ private static byte[] resultsTagBytes;
+ private final ByteArrayInputStream suffix = new ByteArrayInputStream("".getBytes("UTF-8"));
+ private ByteArrayInputStream beforeResultsBuffer;
+ private boolean wrotePrefix;
+
+ private byte[] oneByte = new byte[1];
+
+ static {
+ try {
+ resultsTagBytes = "results".getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ //should not be thrown because UTF-8 is supported
+ throw new RuntimeException(e);
+ }
+ }
+
+ InsertRootElementFilterInputStream(InputStream in) throws IOException {
+ // Wrap in with a pushback stream so we can write our modified version back
+ // onto the beginning of it.
+ super(new PushbackInputStream(in, REREAD_BUFFER_SIZE));
+
+ PushbackInputStream pin = (PushbackInputStream)this.in;
+
+ // Read bytes until we reach '>', then push everything we read, followed by "",
+ // back onto the stream. If we run out of input before we reach '>', then don't
+ // modify the stream.
+ ByteArrayOutputStream beforeResultsChars = new ByteArrayOutputStream();
+ beforeResultsBuffer = new ByteArrayInputStream(new byte[0]);
+
+ int ch;
+ while (true) {
+ ch = this.in.read();
+ if (ch == -1) {
+ // Never found a results element to write after, don't touch the stream.
+ wrotePrefix = false;
+ pin.unread(beforeResultsChars.toByteArray());
+ return;
+ } else if (ch == (int)'<') {
+ boolean resultsTag = isResultsTag(pin);
+
+ if (resultsTag) {
+ // If we reach here, the extension succeeded, so we insert , unread everything,
+ // and return.
+
+ // Unread the match.
+ pin.unread(InsertRootElementFilterInputStream.resultsTagBytes);
+ // Unread the opening '<' that led to our extension
+ pin.unread(ch);
+ // Add a '' element to our read characters
+ beforeResultsChars.write("".getBytes("UTF-8"));
+ beforeResultsBuffer = new ByteArrayInputStream(beforeResultsChars.toByteArray());
+ wrotePrefix = true;
+ return;
+ } else {
+ // Extension didn't find a match. Put the byte on and continue.
+ beforeResultsChars.write(ch);
+ }
+ } else {
+ // Not a character of interest. Put it on the buffer and continue.
+ beforeResultsChars.write(ch);
+ }
+ }
+ }
+
+ private boolean isResultsTag(PushbackInputStream pin) throws IOException {
+ // Try extending
+ ByteArrayOutputStream atResultsChars = new ByteArrayOutputStream();
+ int ech;
+ boolean resultsTag = true;
+ for (byte b : resultsTagBytes) {
+ ech = this.in.read();
+ atResultsChars.write(ech);
+ if (ech != b) {
+ // Extension failed. Put the bytes back on and search again.
+ pin.unread(atResultsChars.toByteArray());
+ resultsTag = false;
+ break;
+ }
+ }
+ return resultsTag;
+ }
+
+ @Override
+ public int read(byte[] buffer, int offset, int length) throws IOException {
+ // first we read from the buffer before the first results xml tag
+ int result = 0;
+ int availableFromBuffer = beforeResultsBuffer.available();
+ if (offset < availableFromBuffer) {
+ result = beforeResultsBuffer.read(buffer, offset, length);
+ if (length <= result) {
+ return result;
+ }
+ }
+
+ // then we read from the original input stream
+ result += in.read(buffer, offset+result, length-result);
+ if (result == -1 && wrotePrefix) {
+ // No more bytes to read from in, and we have written '' earlier in the stream
+ return suffix.read(buffer, offset, length);
+ } else {
+ // in still has data to return, so we return it.
+ return result;
+ }
+ }
+
+ @Override
+ public int read() throws IOException {
+ // Override to dispatch to the other read method. The third overload of read in FilterInputStream
+ // already dispatches to read(byte[], int, int).
+ if (read(oneByte, 0, 1) == -1) {
+ return -1;
+ } else {
+ return oneByte[0];
+ }
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/Job.java b/splunk/src/main/java/com/splunk/Job.java
new file mode 100644
index 00000000..354d413c
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/Job.java
@@ -0,0 +1,973 @@
+/*
+ * 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.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The {@code Job} class represents a job, which is an individual
+ * instance of a running or completed search or report, along with its related
+ * output.
+ */
+public class Job extends Entity {
+
+ private boolean isReady = false;
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The search jobs endpoint.
+ * @param sid The sid of the job.
+ */
+ Job(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the action path.
+ *
+ * @param action The requested action.
+ * @return The action path.
+ */
+ @Override protected String actionPath(String action) {
+ if (action.equals("control"))
+ return path + "/control";
+ return super.actionPath(action);
+ }
+
+ /**
+ * 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.
+ * @return The search job.
+ */
+ public Job control(String action) {
+ return control(action, null);
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Stops the current search and deletes the result cache.
+ *
+ * @return The search job.
+ */
+ public Job cancel() {
+ try {
+ return control("cancel");
+ } catch (HttpException e) {
+ if (e.getStatus() == 404) {
+ // Already cancelled; cancel is a nop.
+ } else {
+ throw e;
+ }
+ }
+ return this;
+ }
+
+ /**
+ * Checks whether the job is ready to be accessed, and throws an exception
+ * if it is not.
+ */
+ private void checkReady() {
+ if (!isReady()) throw new SplunkException(SplunkException.JOB_NOTREADY,
+ "Job not yet scheduled by server");
+ }
+
+ /**
+ * Disables preview for this job.
+ *
+ * @return The search job.
+ */
+ public Job disablePreview() {
+ return control("disablepreview");
+ }
+
+ /**
+ * Enables preview for this job (although it might slow search
+ * considerably).
+ *
+ * @return The search job.
+ */
+ public Job enablePreview() {
+ return control("enablepreview");
+ }
+
+ /**
+ * Stops the job and provides intermediate results available for retrieval.
+ *
+ * @return The search job.
+ */
+ public Job finish() {
+ return control("finalize");
+ }
+
+ /**
+ * Pauses the current search.
+ *
+ * @return The search job.
+ */
+ public Job pause() {
+ return control("pause");
+ }
+
+ /**
+ * Returns the earliest time from which no events are later scanned.
+ * (Use this as a progress indicator.)
+ * @see #getLatestTime
+ * @see #getEarliestTime
+ * @see #getDoneProgress
+ *
+ * @return The earliest time.
+ */
+ public Date getCursorTime() {
+ checkReady();
+ return getDate("cursorTime");
+ }
+
+ /**
+ * Returns a value that indicates how jobs were started (such as the
+ * scheduler).
+ *
+ * @return The delegate, or {@code null} if not specified.
+ */
+ public String getDelegate() {
+ checkReady();
+ return getString("delegate", null);
+ }
+
+ /**
+ * Returns the disk usage for this job.
+ *
+ * @return The disk usage, in bytes.
+ */
+ public int getDiskUsage() {
+ checkReady();
+ return getInteger("diskUsage");
+ }
+
+ /**
+ * Returns the dispatch state for this job.
+ * Valid values are: QUEUED, PARSING, RUNNING, PAUSED, FINALIZING, FAILED,
+ * or DONE.
+ *
+ * @return This job's dispatch state.
+ */
+ public String getDispatchState() {
+ checkReady();
+ return getString("dispatchState");
+ }
+
+ /**
+ * Returns the approximate progress of the job, in the range of 0.0 to 1.0.
+ *
+ * {@code doneProgress = (latestTime-cursorTime)/(latestTime-earliestTime)}
+ * @see #getLatestTime
+ * @see #getCursorTime
+ * @see #getEarliestTime
+ *
+ * @return This job's progress.
+ */
+ public float getDoneProgress() {
+ checkReady();
+ return getFloat("doneProgress");
+ }
+
+ /**
+ * Returns the number of possible events that were dropped due to the
+ * {@code rt_queue_size} (the number of events that the indexer should use
+ * for this search). For real-time searches only.
+ *
+ * @return The number of dropped events.
+ */
+ public int getDropCount() {
+ checkReady();
+ return getInteger("dropCount", 0);
+ }
+
+ /**
+ * Returns the earliest time in the time range to search.
+ * @see #getLatestTime
+ * @see #getCursorTime
+ * @see #getDoneProgress
+ *
+ * @return The earliest time, in UTC format.
+ */
+ public Date getEarliestTime() {
+ checkReady();
+ return getDate("earliestTime");
+ }
+
+ /**
+ * Returns the count of events stored by search that are available to be
+ * retrieved from the events endpoint.
+ *
+ * @return The count of available events.
+ */
+ public int getEventAvailableCount() {
+ checkReady();
+ return getInteger("eventAvailableCount");
+ }
+
+ /**
+ * Returns the count of events (pre-transforming) that were generated.
+ *
+ * @return The number of events.
+ */
+ public int getEventCount() {
+ checkReady();
+ return getInteger("eventCount");
+ }
+
+ /**
+ * Returns the count of events (pre-transforming) that were generated as a long.
+ *
+ * @return The number of events.
+ */
+ public long getEventCountLong() {
+ checkReady();
+ return getLong("eventCount");
+ }
+
+ /**
+ * Returns the count of event fields.
+ *
+ * @return The number of event fields.
+ */
+ public int getEventFieldCount() {
+ checkReady();
+ return getInteger("eventFieldCount");
+ }
+
+ /**
+ * Indicates whether the events from this job are available by streaming.
+ *
+ * @return {@code true} if events can be streamed, {@code false} if not.
+ */
+ public boolean getEventIsStreaming() {
+ checkReady();
+ return getBoolean("eventIsStreaming");
+ }
+
+ /**
+ * Indicates whether any events from this job have not been stored.
+ * @return {@code true} if the event return is truncated, {@code false} if
+ * not.
+ */
+ public boolean getEventIsTruncated() {
+ checkReady();
+ return getBoolean("eventIsTruncated");
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for this job's events.
+ *
+ * @return The event {@code InputStream} IO handle.
+ */
+ public InputStream getEvents() {
+ checkReady();
+ return getEvents(null);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for this job's events.
+ *
+ * @param args Optional arguments.
+ * For a list of possible parameters, see the Request parameters for the
+ * GET search/jobs/{search_id}/events
+ * endpoint in the REST API documentation.
+ *
+ * @return The event {@code InputStream} IO handle.
+ */
+ public InputStream getEvents(Map args) {
+ return getEventsMethod("/events", args);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for this job's events.
+ *
+ * @param args Optional arguments (see {@link JobEventsArgs}).
+ *
+ * @return The event {@code InputStream} IO handle.
+ */
+ // NOTE: This overload exists primarily to provide better documentation
+ // for the "args" parameter.
+ public InputStream getEvents(JobEventsArgs args) {
+ checkReady();
+ return getEvents((Map) args);
+ }
+
+ /**
+ * Returns the subset of the entire search that is before any transforming
+ * commands. The original search should be the "eventSearch" +
+ * "reportSearch".
+ * @see #getReportSearch
+ * @return The event search query.
+ */
+ public String getEventSearch() {
+ checkReady();
+ return getString("eventSearch", null);
+ }
+
+ /**
+ * Returns a value that indicates how events are sorted.
+ *
+ * @return "asc" if events are sorted in time order (oldest first),
+ * "desc" if events are sorted in inverse time order (latest first),
+ * or "none" if events are not sorted.
+ */
+ public String getEventSorting() {
+ checkReady();
+ return getString("eventSorting");
+ }
+
+ private InputStream getEventsMethod(String methodPath, Map args) {
+ checkReady();
+
+ if (args == null) {
+ args = new HashMap();
+ }
+ if (!args.containsKey("segmentation")) {
+ // By default, don't include notations in the results to highlight
+ // search terms (i.e., elements in XML output).
+ args.put("segmentation", "none");
+ }
+
+ // Splunk version pre-9.0 doesn't support v2
+ // v1(GET), v2(POST)
+ String fullPath;
+ ResponseMessage response;
+ if (!service.enableV2SearchApi()) {
+ fullPath = path.replace(JobCollection.REST_PATH_V2, JobCollection.REST_PATH) + methodPath;
+ response = service.get(fullPath, args);
+ }
+ else {
+ fullPath = path.replace(JobCollection.REST_PATH, JobCollection.REST_PATH_V2) + methodPath;
+ response = service.post(fullPath, args);
+ }
+
+ return response.getContent();
+ }
+
+ /**
+ * Returns all positive keywords used by this job. A positive keyword is
+ * a keyword that is not in a NOT clause.
+ *
+ * @return The search job keywords.
+ */
+ public String getKeywords() {
+ checkReady();
+ return getString("keywords", null);
+ }
+
+ /**
+ * Returns this job's label.
+ *
+ * @return The search job label.
+ */
+ public String getLabel() {
+ checkReady();
+ return getString("label", null);
+ }
+
+ /**
+ * Returns the latest time in the time range to search.
+ * @see #getCursorTime
+ * @see #getEarliestTime
+ * @see #getDoneProgress
+ *
+ * @return The latest time, in UTC format.
+ */
+ public Date getLatestTime() {
+ checkReady();
+ return getDate("latestTime");
+ }
+
+ /**
+ * Returns this job's name (its search ID).
+ *
+ * @return The search job name.
+ */
+ @Override public String getName() {
+ checkReady();
+ return getSid();
+ }
+
+ /**
+ * Returns the number of previews that have been generated so far for this
+ * job.
+ *
+ * @return The number of previews.
+ */
+ public int getNumPreviews() {
+ checkReady();
+ return getInteger("numPreviews");
+ }
+
+ /**
+ * Returns this job's priority in the range of 0-10.
+ *
+ * @return The search job priority.
+ */
+ public int getPriority() {
+ checkReady();
+ return getInteger("priority");
+ }
+
+ /**
+ * Sets this job's priority in the range of 0-10.
+ *
+ * @param value The new priority.
+ */
+ public void setPriority(int value) {
+ checkReady();
+ control("setpriority", new Args("priority", value));
+ }
+
+ /**
+ * Returns the search string that is sent to every search peer for this job.
+ *
+ * @return The remote search query string.
+ */
+ public String getRemoteSearch() {
+ checkReady();
+ return getString("remoteSearch", null);
+ }
+
+ /**
+ * Returns the reporting subset of this search, which is the streaming part
+ * of the search that is send to remote providers if reporting commands are
+ * used. The original search should be the "eventSearch" + "reportSearch".
+ * @see #getEventSearch
+ *
+ * @return The reporting search query.
+ */
+ public String getReportSearch() {
+ checkReady();
+ return getString("reportSearch", null);
+ }
+
+ /**
+ * Returns the total count of results returned for this search job.
+ * This is the subset of scanned events that actually matches the search
+ * terms.
+ *
+ * @return The number of results.
+ */
+ public int getResultCount() {
+ checkReady();
+ return getInteger("resultCount");
+ }
+
+ /**
+ * Returns the total count of results returned for this search job as a long.
+ * This is the subset of scanned events that actually matches the search
+ * terms.
+ *
+ * @return The number of results.
+ */
+ public long getResultCountLong() {
+ checkReady();
+ return getLong("resultCount");
+ }
+
+ /**
+ * Indicates whether the job's results are available by streaming.
+ *
+ * @return {@code true} if results can be streamed, {@code false} if not.
+ */
+ public boolean getResultIsStreaming() {
+ checkReady();
+ return getBoolean("resultIsStreaming");
+ }
+
+ /**
+ * Returns the number of result rows in the latest preview results for this
+ * job.
+ *
+ * @return The number of result rows.
+ */
+ public int getResultPreviewCount() {
+ checkReady();
+ return getInteger("resultPreviewCount");
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the results from this job.
+ *
+ * @return The results {@code InputStream} IO handle.
+ */
+ public InputStream getResults() {
+ checkReady();
+ return getResults(null);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the results from this job.
+ *
+ * @param args Optional arguments.
+ * For a list of possible parameters, see the Request parameters for the
+ * GET search/jobs/{search_id}/results
+ * endpoint in the REST API documentation.
+ * @return The results {@code InputStream} IO handle.
+ */
+ public InputStream getResults(Map args) {
+ return getEventsMethod("/results", args);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the results from this job.
+ *
+ * @param args Optional arguments (see {@link JobResultsArgs}).
+ * @return The results {@code InputStream} IO handle.
+ */
+ // NOTE: This overload exists primarily to provide better documentation
+ // for the "args" parameter.
+ public InputStream getResults(JobResultsArgs args) {
+ checkReady();
+ return getResults((Map) args);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the preview results from
+ * this job.
+ *
+ * @return The preview results {@code InputStream} IO handle.
+ */
+ public InputStream getResultsPreview() {
+ checkReady();
+ return getResultsPreview(null);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the preview results from
+ * this job.
+ *
+ * @param args Optional arguments.
+ * For a list of possible parameters, see the Request parameters for the
+ * GET search/jobs/{search_id}/results_preview
+ * endpoint in the REST API documentation.
+ * @return The preview results {@code InputStream} IO handle.
+ */
+ public InputStream getResultsPreview(Map args) {
+ return getEventsMethod("/results_preview", args);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the preview results from
+ * this job.
+ *
+ * @param args Optional arguments (see {@link JobResultsPreviewArgs}).
+ * @return The preview results {@code InputStream} IO handle.
+ */
+ // NOTE: This overload exists primarily to provide better documentation
+ // for the "args" parameter.
+ public InputStream getResultsPreview(JobResultsPreviewArgs args) {
+ checkReady();
+ return getResultsPreview((Map) args);
+ }
+
+ /**
+ * Returns the time that the search job took to complete.
+ *
+ * @return The run-time duration, in seconds.
+ */
+ public float getRunDuration() {
+ checkReady();
+ return getFloat("runDuration");
+ }
+
+ /**
+ * Returns the number of events that are scanned or read off disk.
+ *
+ * @return The number of events.
+ */
+ public int getScanCount() {
+ checkReady();
+ return getInteger("scanCount");
+ }
+
+ /**
+ * Returns the number of events that are scanned or read off disk
+ * as a long.
+ *
+ * @return The number of events.
+ */
+ public long getScanCountLong() {
+ checkReady();
+ return getLong("scanCount");
+ }
+
+ /**
+ * Returns this job's search title.
+ *
+ * @return The search title.
+ */
+ public String getSearch() {
+ checkReady();
+ return getTitle();
+ }
+
+ /**
+ * Returns the earliest time in the time range to search.
+ * @see #getLatestTime
+ * @see #getCursorTime
+ * @see #getDoneProgress
+ *
+ * @return This earliest search time, in epoch format.
+ */
+ public String getSearchEarliestTime() {
+ checkReady();
+ return getString("searchEarliestTime", null);
+ }
+
+ /**
+ * Returns the latest time in the time range to search.
+ * @see #getEarliestTime
+ * @see #getCursorTime
+ * @see #getDoneProgress
+ *
+ * @return The latest search time, in epoch format.
+ */
+ public String getSearchLatestTime() {
+ checkReady();
+ return getString("searchLatestTime", null);
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle to the search log for this job.
+ *
+ * @return The search log {@code InputStream} IO handle.
+ */
+ public InputStream getSearchLog() {
+ checkReady();
+ return getSearchLog(null);
+ }
+
+ /**
+ * 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 a list of search peers that were contacted for this search.
+ *
+ * @return The search peers.
+ */
+ public String[] getSearchProviders() {
+ checkReady();
+ return getStringArray("searchProviders", null);
+ }
+ /**
+ * Returns the unique search identifier (SID) for this job.
+ *
+ * @return The job's SID.
+ */
+ public String getSid() {
+ return getString("sid");
+ }
+
+ /**
+ * Returns this job's search ID from within a response message.
+ *
+ * @param response The response message.
+ * @return This job's SID.
+ */
+ static String getSid(ResponseMessage response) {
+ return Xml.parse(response.getContent())
+ .getElementsByTagName("sid")
+ .item(0)
+ .getTextContent();
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the summary for this job.
+ *
+ * @return The summary {@code InputStream} IO handle.
+ */
+ public InputStream getSummary() {
+ checkReady();
+ return getSummary(null);
+ }
+
+ /**
+ * 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
+ * GET search/jobs/{search_id}/summary
+ * 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();
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the summary for this job.
+ *
+ * @param args Optional arguments (see {@link JobSummaryArgs}).
+ * @return The summary {@code InputStream} IO handle.
+ */
+ // NOTE: This overload exists primarily to provide better documentation
+ // for the "args" parameter.
+ public InputStream getSummary(JobSummaryArgs args) {
+ checkReady();
+ return getSummary((Map) args);
+ }
+
+ /**
+ * Returns the maximum number of timeline buckets for this job.
+ *
+ * @return The number of timeline buckets.
+ */
+ public int getStatusBuckets() {
+ checkReady();
+ return getInteger("statusBuckets");
+ }
+
+ /**
+ * Returns the {@code InputStream} IO handle for the timeline for this job.
+ *
+ * @return The timeline {@code InputStream} IO handle.
+ */
+ public InputStream getTimeline() {
+ checkReady();
+ return getTimeline(null);
+ }
+
+ /**
+ * 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();
+ }
+
+ /**
+ * Returns this job's time to live--that is, the time
+ * before the search job expires and is still available.
+ * If this value is 0, it means the job has expired.
+ *
+ * @return The time to live, in seconds.
+ */
+ public int getTtl() {
+ checkReady();
+ return getInteger("ttl");
+ }
+
+ /**
+ * Indicates whether the job is done.
+ *
+ * @return {@code true} if the job is done, {@code false} if not.
+ */
+ public boolean isDone() {
+ if (!isReady())
+ return false;
+ if (!getBoolean("isDone")) {
+ this.refresh();
+ }
+ return getBoolean("isDone");
+ }
+
+ /**
+ * Indicates whether the job failed.
+ *
+ * @return {@code true} if the job failed, {@code false} if not.
+ */
+ public boolean isFailed() {
+ checkReady();
+ return getBoolean("isFailed");
+ }
+
+ /**
+ * Indicates whether the job is finalized (forced to finish).
+ *
+ * @return {@code true} if the job is finalized, {@code false} if not.
+ */
+ public boolean isFinalized() {
+ checkReady();
+ return getBoolean("isFinalized");
+ }
+
+ /**
+ * Indicates whether the job is paused.
+ *
+ * @return {@code true} if the job is paused, {@code false} if not.
+ */
+ public boolean isPaused() {
+ checkReady();
+ return getBoolean("isPaused");
+ }
+
+ /**
+ * Indicates whether preview for the job is enabled.
+ *
+ * @return {@code true} if preview is enabled, {@code false} if not.
+ */
+ public boolean isPreviewEnabled() {
+ checkReady();
+ return getBoolean("isPreviewEnabled");
+ }
+
+ /**
+ * Indicates whether the job has been scheduled and is ready to
+ * return data.
+ *
+ * @return {@code true} if the job is ready to return data, {@code false} if
+ * not.
+ */
+ public boolean isReady() {
+ if (!isReady) {
+ this.refresh();
+ }
+ return isReady;
+ }
+
+ /**
+ * Indicates whether the job is a real-time search.
+ *
+ * @return {@code true} if the job is a real-time search, {@code false} if
+ * not.
+ */
+ public boolean isRealTimeSearch() {
+ checkReady();
+ return getBoolean("isRealTimeSearch");
+ }
+
+ /**
+ * Indicates whether the job has a remote timeline component.
+ *
+ * @return {@code true} if the job has a remote timeline component,
+ * {@code false} if not.
+ */
+ public boolean isRemoteTimeline() {
+ checkReady();
+ return getBoolean("isRemoteTimeline");
+ }
+
+ /**
+ * Indicates whether the job is to be saved indefinitely.
+ *
+ * @return {@code true} if the job has been saved, {@code false} if not.
+ */
+ public boolean isSaved() {
+ checkReady();
+ return getBoolean("isSaved");
+ }
+
+ /**
+ * Indicates whether this job was run as a saved search (via scheduler).
+ *
+ * @return {@code true} if the job is from a saved search, {@code false}
+ * if not.
+ */
+ public boolean isSavedSearch() {
+ checkReady();
+ return getBoolean("isSavedSearch");
+ }
+
+ /**
+ * Indicates whether the process running the search is dead but with the
+ * search not finished.
+ *
+ * @return {@code true} if the job is a zombie, {@code false} if not.
+ */
+ public boolean isZombie() {
+ checkReady();
+ return getBoolean("isZombie");
+ }
+
+ // Job "entities" don't return an AtomFeed, only an AtomEntry.
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Unsupported. Removes this job. This method is unsupported and will throw
+ * an exception.
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
+
diff --git a/splunk/src/main/java/com/splunk/JobArgs.java b/splunk/src/main/java/com/splunk/JobArgs.java
new file mode 100644
index 00000000..d0f5eaf4
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobArgs.java
@@ -0,0 +1,391 @@
+/*
+ * 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;
+
+/**
+ * The {@code JobArgs} class contains arguments for creating a {@link Job}.
+ */
+public class JobArgs extends Args {
+
+ /**
+ * Specifies how to create a job using the {@link JobCollection#create}
+ * method.
+ */
+ public static enum ExecutionMode {
+ /** Runs a search asynchronously and returns a search job immediately.*/
+ NORMAL("normal"),
+ /** Runs a search synchronously and does not return a search job until
+ * the search has finished. */
+ BLOCKING("blocking"),
+ /** Runs a blocking search that is scheduled to run immediately, then
+ * returns the results of the search once completed. */
+ ONESHOT("oneshot");
+
+ private String value;
+
+ private ExecutionMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Specifies how to create a job using the {@link JobCollection#create}
+ * method.
+ */
+ public static enum SearchMode {
+ /**
+ * Searches historical data.
+ */
+ NORMAL("normal"),
+ /**
+ * Searches live data. A real-time search may also be specified by
+ * setting the "earliest_time" and "latest_time" parameters to begin
+ * with "rt", even if the search_mode is set to "normal" or is not set.
+ *
+ * If both the "earliest_time" and "latest_time" parameters are set to
+ * "rt", the search represents all appropriate live data that was
+ * received since the start of the search.
+ *
+ * If both the "earliest_time" and "latest_time" parameters are set to
+ * "rt" followed by a relative time specifier, a sliding window is used
+ * where the time bounds of the window are determined by the relative
+ * time specifiers and are continuously updated based on current time.
+ */
+ REALTIME("realtime");
+
+ private String value;
+
+ private SearchMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Class constructor.
+ */
+ public JobArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the number of seconds of inactivity after which to automatically cancel a job. A value of 0 means never auto-cancel.
+ *
+ * @param autoCancel
+ * The number of seconds after which to cancel a job.
+ */
+ public void setAutoCancel(int autoCancel) {
+ this.put("auto_cancel", autoCancel);
+ }
+
+ /**
+ * Sets the number of events to process after which to auto-finalize the search. A value of 0 means no limit.
+ *
+ * @param autoFinalizeEventCount
+ * The number of events.
+ */
+ public void setAutoFinalizeEventCount(int autoFinalizeEventCount) {
+ this.put("auto_finalize_ec", autoFinalizeEventCount);
+ }
+
+ /**
+ * Sets the number of seconds of inactivity after which to automatically pause a job. A value of 0 means never auto-pause.
+ *
+ * @param autoPause
+ * The number of seconds after which to pause.
+ */
+ public void setAutoPause(int autoPause) {
+ this.put("auto_pause", autoPause);
+ }
+
+ /**
+ * Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param earliestTime
+ * The earliest time.
+ */
+ public void setEarliestTime(String earliestTime) {
+ this.put("earliest_time", earliestTime);
+ }
+
+ /**
+ * Indicates whether to enable lookups for this search. Enabling lookups might slow searches significantly depending on the nature of the lookups.
+ *
+ * @param enableLookups
+ * {@code true} to enable lookups, {@code false} if not.
+ */
+ public void setEnableLookups(boolean enableLookups) {
+ this.put("enable_lookups", enableLookups);
+ }
+
+ /**
+ * Sets the type of search to run ("blocking", "oneshot", or "normal").
+ *
+ * @param executionMode
+ * The search type.
+ */
+ public void setExecutionMode(ExecutionMode executionMode) {
+ this.put("exec_mode", executionMode);
+ }
+
+ /**
+ * Specifies whether this search should cause (and wait depending on the value of {@code setSynchronizeBundleReplication}) bundle synchronization with all search peers.
+ *
+ * @param forceBundleReplication
+ * {@code true} if this search should cause bundle synchronization,
+ * {@code false} if not.
+ */
+ public void setForceBundleReplication(boolean forceBundleReplication) {
+ this.put("force_bundle_replication", forceBundleReplication);
+ }
+
+ /**
+ * Sets a search ID (SID). If unspecified, a random ID is generated.
+ *
+ * @param id
+ * The search ID.
+ */
+ public void setId(String id) {
+ this.put("id", id);
+ }
+
+ /**
+ * Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param latestTime
+ * The latest time.
+ */
+ public void setLatestTime(String latestTime) {
+ this.put("latest_time", latestTime);
+ }
+
+ /**
+ * Sets the number of events that can be accessible in any given status bucket. Also, in transforming mode, this sets the maximum number of results to store. Specifically, in all calls, {@code codeoffset + count <= max_count}.
+ *
+ * @param maximumCount
+ * The maximum count of events.
+ */
+ public void setMaximumCount(int maximumCount) {
+ this.put("max_count", maximumCount);
+ }
+
+ /**
+ * Sets the maximum number of seconds to run this search before finalizing. Specify 0 to never finalize.
+ *
+ * @param maximumTime
+ * The maximum time, in seconds.
+ */
+ public void setMaximumTime(int maximumTime) {
+ this.put("max_time", maximumTime);
+ }
+
+ /**
+ * Specifies the application namespace to which to restrict searches.
+ *
+ * @param namespace
+ * The namespace.
+ */
+ public void setNamespace(String namespace) {
+ this.put("namespace", namespace);
+ }
+
+ /**
+ * Specifies a time string that sets the absolute time used for any relative time specifier in the search. This value defaults to the current system time.
You can specify a relative time modifier for this parameter. For example, specify +2d to specify the current time plus two days. If you specify a relative time modifier both in this parameter and in the search string, the search string modifier takes precedence.
For information about relative time modifiers, see Time modifiers for search in the Search Reference.
+ *
+ * @param now
+ * The time string.
+ */
+ public void setNow(String now) {
+ this.put("now", now);
+ }
+
+ /**
+ * Sets the time to wait between running the MapReduce phase on accumulated
+ * map values.
+ *
+ * @param reduceFrequency
+ * The time to wait, in seconds.
+ */
+ public void setReduceFrequency(int reduceFrequency) {
+ this.put("reduce_freq", reduceFrequency);
+ }
+
+ /**
+ * Indicates whether to reload macro definitions from the macros.conf configuration file.
+ *
+ * @param reloadMacros
+ * {@code true} to reload macro definitions, {@code false} if not.
+ */
+ public void setReloadMacros(boolean reloadMacros) {
+ this.put("reload_macros", reloadMacros);
+ }
+
+ /**
+ * Sets a list of (possibly wildcarded) servers from which to pull raw events. This same server list is used in subsearches.
+ *
+ * @param remoteServerList
+ * The list of servers.
+ */
+ public void setRemoteServerList(String[] remoteServerList) {
+ StringBuilder csv = new StringBuilder();
+ for (int i = 0, n = remoteServerList.length; i < n; i++) {
+ if (i != 0) {
+ csv.append(",");
+ }
+ csv.append(remoteServerList[i]);
+ }
+
+ this.put("remote_server_list", String.valueOf(csv));
+ }
+
+ /**
+ * Sets one or more required fields to the search. These fields, even if not referenced or used directly by the search, are still included by the events and summary endpoints. Splunk Web uses these fields to prepopulate panels in the Search view.
+ *
+ * @param requiredFieldList
+ * The list of fields.
+ */
+ public void setRequiredFieldList(String[] requiredFieldList) {
+ this.put("rf", requiredFieldList);
+ }
+
+ /**
+ * Indicates whether the indexer blocks if the queue for this search is
+ * full. Only applies to real-time searches.
+ *
+ * @param realtimeBlocking
+ * {@code true} to block the indexer for a full queue, {@code false} if not.
+ */
+ public void setRealtimeBlocking(boolean realtimeBlocking) {
+ this.put("rt_blocking", realtimeBlocking);
+ }
+
+ /**
+ * Indicates whether the indexer pre-filters events. Only applies to real-time searches.
+ *
+ * @param realtimeIndexFilter
+ * {@code true} to pre-filter events, {@code false} if not.
+ */
+ public void setRealtimeIndexFilter(boolean realtimeIndexFilter) {
+ this.put("rt_indexfilter", realtimeIndexFilter);
+ }
+
+ /**
+ * Sets the number of seconds indicating the maximum time to block. A value of 0 means no limit. For real-time searches with "rt_blocking" set to {@code true}.
+ *
+ * @param realtimeMaximumBlockSeconds
+ * The maximum time to block, in seconds.
+ */
+ public void setRealtimeMaximumBlockSeconds(int realtimeMaximumBlockSeconds) {
+ this.put("rt_maxblocksecs", realtimeMaximumBlockSeconds);
+ }
+
+ /**
+ * Sets the number indicating the queue size (in events) that the indexer
+ * should use for this search. Only applies to real-time searches.
+ *
+ * @param realtimeQueueSize
+ * The queue size, in events.
+ */
+ public void setRealtimeQueueSize(int realtimeQueueSize) {
+ this.put("rt_queue_size", realtimeQueueSize);
+ }
+
+ /**
+ * Sets a string that registers a search state listener with the search. Use the format: {@code search_state;results_condition;http_method;uri;}
For example:
{@code search_listener=onResults;true;POST;/servicesNS/admin/search/saved/search/foobar/notify;}
+ *
+ * @param searchListener
+ * The search listener string.
+ */
+ public void setSearchListener(String searchListener) {
+ this.put("search_listener", searchListener);
+ }
+
+ /**
+ * Sets the search mode ("normal" or "realtime").
+ *
+ * @param searchMode
+ * The search mode.
+ */
+ public void setSearchMode(SearchMode searchMode) {
+ this.put("search_mode", searchMode);
+ }
+
+ /**
+ * Indicates whether the search should run in a separate spawned process. Searches against indexes must run in a separate process.
+ *
+ * @param spawnProcess
+ * {@code true} to run the search in a separate process, {@code false} if not.
+ */
+ public void setSpawnProcess(boolean spawnProcess) {
+ this.put("spawn_process", spawnProcess);
+ }
+
+ /**
+ * Sets the maximum number of status buckets to generate. A value of 0 means to not generate timeline information.
+ *
+ * @param statusBuckets
+ * The maximum number of buckets.
+ */
+ public void setStatusBuckets(int statusBuckets) {
+ this.put("status_buckets", statusBuckets);
+ }
+
+ /**
+ * Indicates whether this search should wait for bundle replication to complete.
+ *
+ * @param synchronizeBundleReplication
+ * {@code true} to wait for bundle replication, {@code false} if not.
+ */
+ public void setSynchronizeBundleReplication(boolean synchronizeBundleReplication) {
+ this.put("sync_bundle_replication", synchronizeBundleReplication);
+ }
+
+ /**
+ * Sets the format for converting a formatted time string from {start,end}_time into UTC seconds. The default value is ISO-8601.
+ *
+ * @param timeFormat
+ * The time format string.
+ */
+ public void setTimeFormat(String timeFormat) {
+ this.put("time_format", timeFormat);
+ }
+
+ /**
+ * Sets the number of seconds to keep this search after processing has stopped.
+ *
+ * @param timeout
+ * The timeout, in seconds.
+ */
+ public void setTimeout(int timeout) {
+ this.put("timeout", timeout);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/JobCollection.java b/splunk/src/main/java/com/splunk/JobCollection.java
new file mode 100644
index 00000000..661e21ff
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobCollection.java
@@ -0,0 +1,132 @@
+/*
+ * 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.Map;
+
+/**
+ * The {@code JobCollection} class represents a collection of jobs. A job
+ * is an individual instance of a running or completed search or report, along
+ * with its related output.
+ */
+public class JobCollection extends EntityCollection {
+ static String oneShotNotAllowed = String.format(
+ "Oneshot not allowed, use service oneshot search method");
+ static final String REST_PATH = "search/jobs";
+ static final String REST_PATH_V2 = "search/v2/jobs";
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ JobCollection(Service service) {
+ super(service, service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH, Job.class);
+ this.refreshArgs.put("count", "0");
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them (see {@link CollectionArgs}).
+ */
+ JobCollection(Service service, Args args) {
+ super(service, service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH, Job.class);
+ this.refreshArgs.put("count", "0");
+ }
+
+ /**
+ * Creates a search with a UTF8 pre-encoded search request.
+ *
+ * Note: You can't create a "oneshot" search using this method.
+ * Instead, use the {@link Service#oneshotSearch} method.
+ *
+ * @param query The search query.
+ * @return The unique search identifier (SID).
+ */
+ public Job create(String query) {
+ return create(query, (Map)null);
+ }
+
+ /**
+ * Creates a search.
+ *
+ * Note: 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();
+
+ String path = service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH;
+ Job job = new Job(service, path + "/" + sid);
+ job.refresh();
+
+ return job;
+ }
+
+ /**
+ * Creates a search.
+ *
+ * Note: 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) for the job.
+ */
+ // NOTE: This overload exists primarily to provide better documentation
+ // for the "args" parameter.
+ public Job create(String query, JobArgs args) {
+ return this.create(query, (Map) args);
+ }
+
+ /**
+ * Returns the job's response.
+ *
+ * @return The job's response.
+ */
+ @Override public ResponseMessage list() {
+ return service.get(path, this.refreshArgs);
+ }
+
+ /**
+ * Returns the job's unique search identifier (SID), which is used as this
+ * item's key.
+ *
+ * @param entry The {@code AtomEntry} response.
+ * @return This job's SID.
+ */
+ @Override protected String itemKey(AtomEntry entry) {
+ return (String)entry.content.get("sid");
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/JobEventsArgs.java b/splunk/src/main/java/com/splunk/JobEventsArgs.java
new file mode 100644
index 00000000..233e3c1b
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobEventsArgs.java
@@ -0,0 +1,210 @@
+/*
+ * 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;
+
+/**
+ * The {@code JobEventsArgs} class contains arguments for getting events using
+ * the {@link Job#getEvents} method.
+ */
+public class JobEventsArgs extends Args {
+
+ /**
+ * Specifies the format for the returned output.
+ */
+ public static enum OutputMode {
+ /** Returns output in Atom format. */
+ ATOM("atom"),
+ /** Returns output in CSV format. */
+ CSV("csv"),
+ /** Returns output in JSON format. */
+ JSON("json"),
+ /** Returns output in JSON_COLS format. */
+ JSON_COLS("json_cols"),
+ /** Returns output in JSON_ROWS format. */
+ JSON_ROWS("json_rows"),
+ /** Returns output in raw format. */
+ RAW("raw"),
+ /** Returns output in XML format. */
+ XML("xml");
+
+ private String value;
+
+ private OutputMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Specifies how to truncate lines to achieve the value in
+ * {@link #setMaximumLines}.
+ */
+ public static enum TruncationMode {
+ /** Use the "abstract" truncation mode.*/
+ ABSTRACT("abstract"),
+ /** Use the "truncate" truncation mode.*/
+ TRUNCATE("truncate");
+
+ private String value;
+
+ private TruncationMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Class constructor.
+ */
+ public JobEventsArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the maximum number of results to return. To return all available results, specify 0. The default value is 100.
+ *
+ * @param count
+ * The maximum number of results.
+ */
+ public void setCount(int count) {
+ this.put("count", count);
+ }
+
+ /**
+ * Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param earliestTime
+ * The earliest time.
+ */
+ public void setEarliestTime(String earliestTime) {
+ this.put("earliest_time", earliestTime);
+ }
+
+ /**
+ * Sets a list of fields to return for the event set.
+ *
+ * @param fieldList
+ * A list of fields.
+ */
+ public void setFieldList(String[] fieldList) {
+ this.put("f", fieldList);
+ }
+
+ /**
+ * Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param latestTime
+ * The latest time.
+ */
+ public void setLatestTime(String latestTime) {
+ this.put("latest_time", latestTime);
+ }
+
+ /**
+ * Sets the maximum number of lines that any single event's _raw field should contain.
+ *
+ * @param maximumLines
+ * The maximum number of lines. For no limit, specify 0.
+ */
+ public void setMaximumLines(int maximumLines) {
+ this.put("max_lines", maximumLines);
+ }
+
+ /**
+ * Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+ *
+ * @param offset
+ * The index of the first result to return.
+ */
+ public void setOffset(int offset) {
+ this.put("offset", offset);
+ }
+
+ /**
+ * Sets the format of the output.
+ *
+ * @param outputMode
+ * The output format.
+ */
+ public void setOutputMode(OutputMode outputMode) {
+ this.put("output_mode", outputMode);
+ }
+
+ /**
+ * Sets a UTC time format.
+ *
+ * @param outputTimeFormat
+ * A UTC time format.
+ */
+ public void setOutputTimeFormat(String outputTimeFormat) {
+ this.put("output_time_format", outputTimeFormat);
+ }
+
+ /**
+ * Sets the post-processing search to apply to results.
+ *
+ * @param search
+ * The post-processing search query.
+ */
+ public void setSearch(String search) {
+ this.put("search", search);
+ }
+
+ /**
+ * Sets the type of segmentation to perform on the data, including an option to perform k/v segmentation.
+ *
+ * @param segmentation
+ * The segmentation type.
+ */
+ public void setSegmentation(String segmentation) {
+ this.put("segmentation", segmentation);
+ }
+
+ /**
+ * Specifies an expression to convert a formatted time string from {start,end}_time into UTC seconds. The default format is "%m/%d/%Y:%H:%M:%S".
+ *
+ * @param timeFormat
+ * The time format.
+ */
+ public void setTimeFormat(String timeFormat) {
+ this.put("time_format", timeFormat);
+ }
+
+ /**
+ * Specifies how to truncate lines to achieve the value in {@link #setMaximumLines}.
+ *
+ * @param truncationMode
+ * The truncation mode.
+ */
+ public void setTruncationMode(TruncationMode truncationMode) {
+ this.put("truncation_mode", truncationMode);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/JobExportArgs.java b/splunk/src/main/java/com/splunk/JobExportArgs.java
new file mode 100644
index 00000000..5d5f8930
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobExportArgs.java
@@ -0,0 +1,447 @@
+/*
+ * 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;
+
+/**
+ * The {@code JobExportArgs} class contains arguments for exporting events using
+ * the {@link Service#export} method.
+ */
+public class JobExportArgs extends Args {
+
+ /**
+ * Specifies the format for the returned output.
+ */
+ public static enum OutputMode {
+ /** Returns output in Atom format. */
+ ATOM("atom"),
+ /** Returns output in CSV format. */
+ CSV("csv"),
+ /** Returns output in JSON format. */
+ JSON("json"),
+ /** Returns output in JSON_COLS format. */
+ JSON_COLS("json_cols"),
+ /** Returns output in JSON_ROWS format. */
+ JSON_ROWS("json_rows"),
+ /** Returns output in raw format. */
+ RAW("raw"),
+ /** Returns output in XML format. */
+ XML("xml");
+
+ private String value;
+
+ private OutputMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Specifies how to create a job using the {@link JobCollection#create}
+ * method.
+ */
+ public static enum SearchMode {
+ /**
+ * Searches historical data.
+ */
+ NORMAL("normal"),
+ /**
+ * Searches live data. A real-time search may also be specified by
+ * setting the "earliest_time" and "latest_time" parameters to begin
+ * with "rt", even if the search_mode is set to "normal" or is not set.
+ *
+ * If both the "earliest_time" and "latest_time" parameters are set to
+ * "rt", the search represents all appropriate live data that was
+ * received since the start of the search.
+ *
+ * If both the "earliest_time" and "latest_time" parameters are set to
+ * "rt" followed by a relative time specifier, a sliding window is used
+ * where the time bounds of the window are determined by the relative
+ * time specifiers and are continuously updated based on current time.
+ */
+ REALTIME("realtime");
+
+ private String value;
+
+ private SearchMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Specifies how to truncate lines to achieve the value in
+ * {@link #setMaximumLines}.
+ */
+ public static enum TruncationMode {
+ /** Use the "abstract" truncation mode.*/
+ ABSTRACT("abstract"),
+ /** Use the "truncate" truncation mode.*/
+ TRUNCATE("truncate");
+
+ private String value;
+
+ private TruncationMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Class constructor.
+ */
+ public JobExportArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Specifies the earliest time in the time range to search, based on the index time. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param indexEarliest
+ * The earliest time.
+ */
+ public void setIndexEarliest(String indexEarliest) {
+ this.put("index_earliest", indexEarliest);
+ }
+
+ /**
+ * Specifies the latest time in the time range to search, based on the index time. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param indexLatest
+ * The latest time.
+ */
+ public void setIndexLatest(String indexLatest) {
+ this.put("index_latest", indexLatest);
+ }
+
+ /**
+ * Sets the format of the output.
+ *
+ * @param outputMode
+ * The output format.
+ */
+ public void setOutputMode(OutputMode outputMode) {
+ this.put("output_mode", outputMode);
+ }
+
+ /**
+ * Sets the number of seconds of inactivity after which to automatically cancel a job. A value of 0 means never auto-cancel.
+ *
+ * @param autoCancel
+ * The number of seconds after which to cancel a job.
+ */
+ public void setAutoCancel(int autoCancel) {
+ this.put("auto_cancel", autoCancel);
+ }
+
+ /**
+ * Sets the number of events to process after which to auto-finalize the search. A value of 0 means no limit.
+ *
+ * @param autoFinalizeEventCount
+ * The number of events.
+ */
+ public void setAutoFinalizeEventCount(int autoFinalizeEventCount) {
+ this.put("auto_finalize_ec", autoFinalizeEventCount);
+ }
+
+ /**
+ * Sets the number of seconds of inactivity after which to automatically pause a job. A value of 0 means never auto-pause.
+ *
+ * @param autoPause
+ * The number of seconds after which to pause.
+ */
+ public void setAutoPause(int autoPause) {
+ this.put("auto_pause", autoPause);
+ }
+
+ /**
+ * Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param earliestTime
+ * The earliest time.
+ */
+ public void setEarliestTime(String earliestTime) {
+ this.put("earliest_time", earliestTime);
+ }
+
+ /**
+ * Indicates whether to enable lookups for this search. Enabling lookups might slow searches significantly depending on the nature of the lookups.
+ *
+ * @param enableLookups
+ * {@code true} to enable lookups, {@code false} if not.
+ */
+ public void setEnableLookups(boolean enableLookups) {
+ this.put("enable_lookups", enableLookups);
+ }
+
+ /**
+ * Specifies whether this search should cause (and wait depending on the value of {@code setSynchronizeBundleReplication}) bundle synchronization with all search peers.
+ *
+ * @param forceBundleReplication
+ * {@code true} if this search should cause bundle synchronization, {@code false} if not.
+ */
+ public void setForceBundleReplication(boolean forceBundleReplication) {
+ this.put("force_bundle_replication", forceBundleReplication);
+ }
+
+ /**
+ * Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param latestTime
+ * The latest time.
+ */
+ public void setLatestTime(String latestTime) {
+ this.put("latest_time", latestTime);
+ }
+
+ /**
+ * Sets the number of seconds to run this search before finalizing. Specify 0 to never finalize.
+ *
+ * @param maximumTime
+ * The maximum time, in seconds.
+ */
+ public void setMaximumTime(int maximumTime) {
+ this.put("max_time", maximumTime);
+ }
+
+ /**
+ * Specifies the application namespace in which to restrict searches.
+ *
+ * @param namespace
+ * The namespace.
+ */
+ public void setNamespace(String namespace) {
+ this.put("namespace", namespace);
+ }
+
+ /**
+ * Specifies a time string that sets the absolute time used for any relative time specifier in the search. This value defaults to the current system time.
You can specify a relative time modifier for this parameter. For example, specify +2d to specify the current time plus two days. If you specify a relative time modifier both in this parameter and in the search string, the search string modifier takes precedence.
For information about relative time modifiers, see Time modifiers for search in the Search Reference.
+ *
+ * @param now
+ * A time string.
+ */
+ public void setNow(String now) {
+ this.put("now", now);
+ }
+
+ /**
+ * Sets the time to wait between running the MapReduce phase on accumulated map values.
+ *
+ * @param reduceFrequency
+ * The time to wait, in seconds.
+ */
+ public void setReduceFrequency(int reduceFrequency) {
+ this.put("reduce_freq", reduceFrequency);
+ }
+
+ /**
+ * Indicates whether to reload macro definitions from the macros.conf configuration file.
+ *
+ * @param reloadMacros
+ * {@code true} to reload macro definitions, {@code false} if not.
+ */
+ public void setReloadMacros(boolean reloadMacros) {
+ this.put("reload_macros", reloadMacros);
+ }
+
+ /**
+ * Sets a list of (possibly wildcarded) servers from which to pull raw events. This same server list is used in subsearches.
+ *
+ * @param remoteServerList
+ * A list of servers.
+ */
+ public void setRemoteServerList(String[] remoteServerList) {
+ StringBuilder csv = new StringBuilder();
+ for (int i = 0, n = remoteServerList.length; i < n; i++) {
+ if (i != 0) {
+ csv.append(",");
+ }
+ csv.append(remoteServerList[i]);
+ }
+
+ this.put("remote_server_list", String.valueOf(csv));
+ }
+
+ /**
+ * Sets one or more fields to the search. These fields, even if not referenced or used directly by the search, are still included by the events and summary endpoints. Splunk Web uses these fields to prepopulate panels in the Search view.
+ *
+ * @param fieldList
+ * The list of fields.
+ */
+ public void setFieldList(String[] fieldList) {
+ this.put("f", fieldList);
+ }
+
+ /**
+ * Sets one or more required fields to the search. These fields, even if not referenced or used directly by the search, are still included by the events and summary endpoints. Splunk Web uses these fields to prepopulate panels in the Search view.
+ *
+ * @param requiredFieldList
+ * The list of required fields.
+ */
+ public void setRequiredFieldList(String[] requiredFieldList) {
+ this.put("rf", requiredFieldList);
+ }
+
+ /**
+ * Indicates whether the indexer blocks if the queue for this search is full. Only applies to real-time searches.
+ *
+ * @param realtimeBlocking
+ * {@code true} to block the indexer for a full queue, {@code false} if not.
+ */
+ public void setRealtimeBlocking(boolean realtimeBlocking) {
+ this.put("rt_blocking", realtimeBlocking);
+ }
+
+ /**
+ * Indicates whether the indexer pre-filters events. Only applies to real-time searches.
+ *
+ * @param realtimeIndexFilter
+ * {@code true} to pre-filter events, {@code false} if not.
+ */
+ public void setRealtimeIndexFilter(boolean realtimeIndexFilter) {
+ this.put("rt_indexfilter", realtimeIndexFilter);
+ }
+
+ /**
+ * Sets the number of seconds indicating the maximum time to block. A value of 0 means no limit. For real-time searches with "rt_blocking" set to {@code true}.
+ *
+ * @param realtimeMaximumBlockSeconds
+ * The maximum time to block, in seconds.
+ */
+ public void setRealtimeMaximumBlockSeconds(int realtimeMaximumBlockSeconds) {
+ this.put("rt_maxblocksecs", realtimeMaximumBlockSeconds);
+ }
+
+ /**
+ * Sets the number indicating the queue size (in events) that the indexer should use for this search. Only applies to real-time searches.
+ *
+ * @param realtimeQueueSize
+ * The queue size, in events.
+ */
+ public void setRealtimeQueueSize(int realtimeQueueSize) {
+ this.put("rt_queue_size", realtimeQueueSize);
+ }
+
+ /**
+ * Sets a string that registers a search state listener with the search. Use the format: {@code search_state;results_condition;http_method;uri;}
For example:
{@code search_listener=onResults;true;POST;/servicesNS/admin/search/saved/search/foobar/notify;}
+ *
+ * @param searchListener
+ * The search listener string.
+ */
+ public void setSearchListener(String searchListener) {
+ this.put("search_listener", searchListener);
+ }
+
+ /**
+ * Sets the search mode ("normal" or "realtime").
+ *
+ * @param searchMode
+ * The search mode.
+ */
+ public void setSearchMode(SearchMode searchMode) {
+ this.put("search_mode", searchMode);
+ }
+
+ /**
+ * Indicates whether this search should wait for bundle replication to complete.
+ *
+ * @param synchronizeBundleReplication
+ * {@code true} to wait for bundle replication, {@code false} if not.
+ */
+ public void setSynchronizeBundleReplication(boolean synchronizeBundleReplication) {
+ this.put("sync_bundle_replication", synchronizeBundleReplication);
+ }
+
+ /**
+ * Sets the format for converting a formatted time string from {start,end}_time into UTC seconds. The default value is ISO-8601.
+ *
+ * @param timeFormat
+ * The time format string.
+ */
+ public void setTimeFormat(String timeFormat) {
+ this.put("time_format", timeFormat);
+ }
+
+ /**
+ * Sets the number of seconds to keep this search after processing has stopped.
+ *
+ * @param timeout
+ * The timeout, in seconds.
+ */
+ public void setTimeout(int timeout) {
+ this.put("timeout", timeout);
+ }
+
+ /**
+ * Sets the maximum number of lines that any single event's _raw field should contain.
+ *
+ * @param maximumLines
+ * The maximum number of lines. For no limit, specify 0.
+ */
+ public void setMaximumLines(int maximumLines) {
+ this.put("max_lines", maximumLines);
+ }
+
+ /**
+ * Sets a UTC time format.
+ *
+ * @param outputTimeFormat
+ * A UTC time format.
+ */
+ public void setOutputTimeFormat(String outputTimeFormat) {
+ this.put("output_time_format", outputTimeFormat);
+ }
+
+ /**
+ * Sets the type of segmentation to perform on the data, including an option to perform k/v segmentation.
+ *
+ * @param segmentation
+ * The segmentation type.
+ */
+ public void setSegmentation(String segmentation) {
+ this.put("segmentation", segmentation);
+ }
+
+ /**
+ * Specifies how to truncate lines to achieve the value in {@link #setMaximumLines}.
+ *
+ * @param truncationMode
+ * The truncation mode.
+ */
+ public void setTruncationMode(TruncationMode truncationMode) {
+ this.put("truncation_mode", truncationMode);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/JobResultsArgs.java b/splunk/src/main/java/com/splunk/JobResultsArgs.java
new file mode 100644
index 00000000..a35bbd8b
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobResultsArgs.java
@@ -0,0 +1,116 @@
+/*
+ * 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;
+
+/**
+ * The {@code JobResultsArgs} class contains arguments for getting job results
+ * using the {@link Job#getResults} method.
+ */
+public class JobResultsArgs extends Args {
+
+ /**
+ * Specifies the format for the returned output.
+ */
+ public static enum OutputMode {
+ /** Returns output in Atom format. */
+ ATOM("atom"),
+ /** Returns output in CSV format. */
+ CSV("csv"),
+ /** Returns output in JSON format. */
+ JSON("json"),
+ /** Returns output in JSON_COLS format. */
+ JSON_COLS("json_cols"),
+ /** Returns output in JSON_ROWS format. */
+ JSON_ROWS("json_rows"),
+ /** Returns output in raw format. */
+ RAW("raw"),
+ /** Returns output in XML format. */
+ XML("xml");
+
+ private String value;
+
+ private OutputMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Class constructor.
+ */
+ public JobResultsArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the maximum number of results to return.
+ *
+ * @param count
+ * The maximum number of results. To return all available results, specify 0.
+ */
+ public void setCount(int count) {
+ this.put("count", count);
+ }
+
+ /**
+ * Sets a list of fields to return for the event set.
+ *
+ * @param fieldList
+ * A list of fields.
+ */
+ public void setFieldList(String[] fieldList) {
+ this.put("f", fieldList);
+ }
+
+ /**
+ * Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+ *
+ * @param offset
+ * The index of the first result to return.
+ */
+ public void setOffset(int offset) {
+ this.put("offset", offset);
+ }
+
+ /**
+ * Sets the format of the output.
+ *
+ * @param outputMode
+ * The output format.
+ */
+ public void setOutputMode(OutputMode outputMode) {
+ this.put("output_mode", outputMode);
+ }
+
+ /**
+ * Sets the post-processing search to apply to results.
+ *
+ * @param search
+ * The post-processing search query.
+ */
+ public void setSearch(String search) {
+ this.put("search", search);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/JobResultsPreviewArgs.java b/splunk/src/main/java/com/splunk/JobResultsPreviewArgs.java
new file mode 100644
index 00000000..d929f010
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobResultsPreviewArgs.java
@@ -0,0 +1,116 @@
+/*
+ * 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;
+
+/**
+ * The {@code JobResultsPreviewArgs} class contains arguments for getting job
+ * results previews using the {@link Job#getResultsPreview} method.
+ */
+public class JobResultsPreviewArgs extends Args {
+
+ /**
+ * Specifies the format for the returned output.
+ */
+ public static enum OutputMode {
+ /** Returns output in Atom format. */
+ ATOM("atom"),
+ /** Returns output in CSV format. */
+ CSV("csv"),
+ /** Returns output in JSON format. */
+ JSON("json"),
+ /** Returns output in JSON_COLS format. */
+ JSON_COLS("json_cols"),
+ /** Returns output in JSON_ROWS format. */
+ JSON_ROWS("json_rows"),
+ /** Returns output in raw format. */
+ RAW("raw"),
+ /** Returns output in XML format. */
+ XML("xml");
+
+ private String value;
+
+ private OutputMode(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return The REST API value for this enumerated constant.
+ */
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Class constructor.
+ */
+ public JobResultsPreviewArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Sets the maximum number of results to return.
+ *
+ * @param count
+ * The maximum number of results. To return all available results, specify 0.
+ */
+ public void setCount(int count) {
+ this.put("count", count);
+ }
+
+ /**
+ * Sets a list of fields to return for the event set.
+ *
+ * @param fieldList
+ * A list of fields.
+ */
+ public void setFieldList(String[] fieldList) {
+ this.put("f", fieldList);
+ }
+
+ /**
+ * Specifies the index of the first result (inclusive) from which to begin returning data. This value is 0-indexed.
In Splunk 4.1+, negative offsets are allowed and are added to the count to compute the absolute offset (for example, offset=-1 is the last available offset). Offsets in the results are always absolute and never negative. The default value is 0.
+ *
+ * @param offset
+ * The index of the first result to return.
+ */
+ public void setOffset(int offset) {
+ this.put("offset", offset);
+ }
+
+ /**
+ * Sets the format of the output.
+ *
+ * @param outputMode
+ * The output format.
+ */
+ public void setOutputMode(OutputMode outputMode) {
+ this.put("output_mode", outputMode);
+ }
+
+ /**
+ * Sets the post-processing search to apply to results.
+ *
+ * @param search
+ * The post-processing search query.
+ */
+ public void setSearch(String search) {
+ this.put("search", search);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/JobSummaryArgs.java b/splunk/src/main/java/com/splunk/JobSummaryArgs.java
new file mode 100644
index 00000000..ff7eff7e
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/JobSummaryArgs.java
@@ -0,0 +1,122 @@
+/*
+ * 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;
+/**
+ * The {@code JobSummaryArgs} class contains arguments for getting a job summary
+ * using the {@link Job#getSummary} method.
+ */
+public class JobSummaryArgs extends Args {
+
+ /**
+ * Class constructor.
+ */
+ public JobSummaryArgs() { super(); }
+
+ /* BEGIN AUTOGENERATED CODE */
+
+ /**
+ * Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param earliestTime
+ * The earliest time.
+ */
+ public void setEarliestTime(String earliestTime) {
+ this.put("earliest_time", earliestTime);
+ }
+
+ /**
+ * Sets a list of fields to return for the event set.
+ *
+ * @param fieldList
+ * A list of fields.
+ */
+ public void setFieldList(String[] fieldList) {
+ this.put("f", fieldList);
+ }
+
+ /**
+ * Indicates whether to add histogram data to the summary output.
+ *
+ * @param histogram
+ * {@code true} to add histogram data, {@code false} if not.
+ */
+ public void setHistogram(boolean histogram) {
+ this.put("histogram", histogram);
+ }
+
+ /**
+ * Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
+ *
+ * @param latestTime
+ * The latest time.
+ */
+ public void setLatestTime(String latestTime) {
+ this.put("latest_time", latestTime);
+ }
+
+ /**
+ * Sets the fraction of results for each key that this key must occur in to be displayed.
+ *
+ * @param minimumFrequency
+ * The frequency, as a fraction (a value between 0 and 1).
+ */
+ public void setMinimumFrequency(double minimumFrequency) {
+ this.put("min_freq", minimumFrequency);
+ }
+
+ /**
+ * Sets a UTC time format.
+ *
+ * @param outputTimeFormat
+ * A UTC time format.
+ */
+ public void setOutputTimeFormat(String outputTimeFormat) {
+ this.put("output_time_format", outputTimeFormat);
+ }
+
+ /**
+ * Sets a search query to filter the response. The response matches field values against the search query. For example, "foo" matches any object that has "foo" as a substring in a field, and "field_name=field_value" restricts the match to a single field.
+ *
+ * @param search
+ * A search substring.
+ */
+ public void setSearch(String search) {
+ this.put("search", search);
+ }
+
+ /**
+ * Specifies an expression to convert a formatted time string from {start,end}_time into UTC seconds. The default format is "%m/%d/%Y:%H:%M:%S".
+ *
+ * @param timeFormat
+ * The time format.
+ */
+ public void setTimeFormat(String timeFormat) {
+ this.put("time_format", timeFormat);
+ }
+
+ /**
+ * Sets for each key how many of the most frequent items to return.
+ *
+ * @param topCount
+ * The number of items to return.
+ */
+ public void setTopCount(int topCount) {
+ this.put("top_count", topCount);
+ }
+
+ /* END AUTOGENERATED CODE */
+}
diff --git a/splunk/src/main/java/com/splunk/License.java b/splunk/src/main/java/com/splunk/License.java
new file mode 100644
index 00000000..0961c3c0
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/License.java
@@ -0,0 +1,164 @@
+/*
+ * 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.Date;
+
+/**
+ * The {@code License} class represents a license, providing access to the
+ * licenses for this Splunk instance. Splunk licenses specify how much data
+ * you can index per calendar day (from midnight to midnight by the clock on
+ * the license master).
+ */
+public class License extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The license endpoint.
+ */
+ License(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the time and date the license was created.
+ *
+ * @return The creation time and date.
+ */
+ public Date getCreationTime() {
+ return getDate("creation_time");
+ }
+
+ /**
+ * Returns the time and date this license expires.
+ *
+ * @return The expiration time and date.
+ */
+ public Date getExpirationTime() {
+ return getDate("expiration_time");
+ }
+
+ /**
+ * Returns a list of enabled features for this license.
+ *
+ * @return The feature list.
+ */
+ public String[] getFeatures() {
+ return getStringArray("features");
+ }
+
+ /**
+ * Returns the group ID for this license.
+ *
+ * @return The license group ID, or {@code null} if not available.
+ */
+ public String getGroupId() {
+ return getString("group_id", null);
+ }
+
+ /**
+ * Returns the label for this license.
+ *
+ * @return This license label, or {@code null} if not available.
+ */
+ public String getLabel() {
+ return getString("label", null);
+ }
+
+ /**
+ * Returns the hash value for this license.
+ *
+ * @return The license hash value.
+ */
+ public String getLicenseHash() {
+ return getString("license_hash");
+ }
+
+ /**
+ * Returns the maximum number of violations allowed for this license.
+ * A violation occurs when you exceed the maximum indexing volume allowed
+ * for your license. Exceeding the maximum violations will disable search.
+ *
+ * @return The maximum number of license violations.
+ */
+ public int getMaxViolations() {
+ return getInteger("max_violations");
+ }
+
+ /**
+ * Returns the daily indexing quota, which is the maximum bytes per day
+ * of indexing volume for this license.
+ *
+ * @return The daily indexing quota, in bytes.
+ */
+ public long getQuota() {
+ return getByteCount("quota");
+ }
+
+ /**
+ * Returns the source types that, when indexed, count against the indexing
+ * volume for this license. All source types are allowed if none
+ * are explicitly specified.
+ *
+ * @return The license source types, or {@code null} if not specified.
+ */
+ public String[] getSourceTypes() {
+ return getStringArray("sourcetypes", null);
+ }
+
+ /**
+ * Returns the stack ID for this license.
+ *
+ * @return The license stack ID.
+ */
+ public String getStackId() {
+ return getString("stack_id");
+ }
+
+ /**
+ * Returns the status of this license.
+ *
+ * @return The license status.
+ */
+ public String getStatus() {
+ return getString("status");
+ }
+
+ /**
+ * Returns the license type.
+ *
+ * @return The license type.
+ */
+ public String getType() {
+ return getString("type");
+ }
+
+ /**
+ * Returns the number of days remaining in the rolling time window
+ * for this license. A license violation occurs when you have
+ * exceeded the number of allowed warnings within this period of
+ * time.
+ *
+ * @return The number of days in the rolling window.
+ */
+ public int getWindowPeriod() {
+ return getInteger("window_period");
+ }
+}
+
diff --git a/splunk/com/splunk/LicenseGroup.java b/splunk/src/main/java/com/splunk/LicenseGroup.java
similarity index 52%
rename from splunk/com/splunk/LicenseGroup.java
rename to splunk/src/main/java/com/splunk/LicenseGroup.java
index 78c1b25c..c0473b7a 100644
--- a/splunk/com/splunk/LicenseGroup.java
+++ b/splunk/src/main/java/com/splunk/LicenseGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,15 @@
package com.splunk;
/**
- * Representation of a License Group.
- */
+* The {@code LicenseGroup} class represents a license group, which is a
+* collection of one or more license stacks.
+*/
public class LicenseGroup extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The license group endpoint.
*/
LicenseGroup(Service service, String path) {
@@ -32,20 +33,31 @@ public class LicenseGroup extends Entity {
}
/**
- * Returns this license group's stack ID, or null if not specified.
+ * Returns the stack IDs of the license stacks in this license group.
*
- * @return This license group's stack ID.
+ * @return The stack IDs, or {@code null} if not specified.
*/
public String[] getStackIds() {
- return getStringArray("stack_ids", null);
+ return getStringArray("stack_ids", new String[]{""});
}
/**
- * Returns whether or not this license group is active.
+ * Indicates whether this license group is active.
*
- * @return Whether or not this license group is active.
+ * @return {@code true} if this license group is active, {@code false}
+ * if not.
*/
public boolean isActive() {
return getBoolean("is_active");
}
+
+ /**
+ * Sets whether this license group is active.
+ *
+ * @param value {@code true} to set this license group as active,
+ * {@code false} for inactive.
+ */
+ public void setActive(boolean value) {
+ setCacheValue("is_active", value);
+ }
}
diff --git a/splunk/com/splunk/LicenseMessage.java b/splunk/src/main/java/com/splunk/LicenseMessage.java
similarity index 56%
rename from splunk/com/splunk/LicenseMessage.java
rename to splunk/src/main/java/com/splunk/LicenseMessage.java
index ab9337b4..8c1fe21b 100644
--- a/splunk/com/splunk/LicenseMessage.java
+++ b/splunk/src/main/java/com/splunk/LicenseMessage.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -19,14 +19,17 @@
import java.util.Date;
/**
- * Representation of a license message.
+ * The {@code LicenseMessage} class represents a license message.
+ * Messages may range from helpful warnings about being close to violations
+ * or licenses expiring, to more severe alerts regarding overages and exceeding
+ * the daily indexing volume limit.
*/
public class LicenseMessage extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The license group endpoint.
*/
LicenseMessage(Service service, String path) {
@@ -34,63 +37,63 @@ public class LicenseMessage extends Entity {
}
/**
- * Returns this license message's category.
+ * Returns the category of this license message.
*
- * @return This license message's category.
+ * @return The category.
*/
public String getCategory() {
return getString("category");
}
/**
- * Returns this license message's creation time.
+ * Returns the time and date that this license message was created.
*
- * @return This license message's creation time.
+ * @return The creation time and date.
*/
public Date getCreationTime() {
- return getDateFromEpoch("create_time");
+ return getDate("create_time");
}
/**
- * Returns this license message's description,, or null if not specified.
+ * Returns the description of this license message.
*
- * @return This license message's description.
+ * @return The description, or {@code null} if not specified.
*/
public String getDescription() {
return getString("description", null);
}
/**
- * Returns this license message's pool ID, or null if not specified.
+ * Returns the pool ID of this license message.
*
- * @return This license message's pool ID.
+ * @return The pool ID, or {@code null} if not specified.
*/
public String getPoolId() {
return getString("pool_id", null);
}
/**
- * Returns this license message's severity, or null if not specified.
+ * Returns the severity of this license message.
*
- * @return This license message's severity.
+ * @return The severity, or {@code null} if not specified.
*/
public String getSeverity() {
return getString("severity", null);
}
/**
- * Returns this license message's slave ID, or null if not specified.
+ * Returns the slave ID of this license message.
*
- * @return this license message's slave ID.
+ * @return The slave ID, or {@code null} if not specified.
*/
public String getSlaveId() {
return getString("slave_id", null);
}
/**
- * Returns this license message's stack ID, or null if not specified.
+ * Returns the stack ID of this license message.
*
- * @return This license message's stack ID.
+ * @return The stack ID, or {@code null} if not specified.
*/
public String getStackId() {
return getString("stack_id", null);
diff --git a/splunk/src/main/java/com/splunk/LicensePool.java b/splunk/src/main/java/com/splunk/LicensePool.java
new file mode 100644
index 00000000..613fcaac
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/LicensePool.java
@@ -0,0 +1,173 @@
+/*
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+* The {@code LicensePool} class represents a license pool, which is made up
+* of a single license master and zero or more license slave instances of Splunk
+* that are configured to use the licensing volume from a set license or license
+ * stack.
+ */
+public class LicensePool extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The license pool endpoint.
+ */
+ LicensePool(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the description of this license pool.
+ *
+ * @return The description, or {@code null} if not specified.
+ */
+ public String getDescription() {
+ return getString("description", null);
+ }
+
+ /**
+ * Returns the indexing quota for this license pool.
+ *
+ * @return A string containing the indexing quota in bytes, or "MAX" to
+ * indicate the maximum amount that is allowed.
+ */
+ public String getQuota() {
+ return getString("quota", "0");
+ }
+
+ /**
+ * Returns the list of slaves for this license pool.
+ *
+ * @return A comma-separated list of slaves by ID, or {@code null} if not
+ * specified.
+ */
+ public String[] getSlaves() {
+ if (toUpdate.containsKey("slaves")) {
+ String value = (String)toUpdate.get("slaves");
+ return value.split(",");
+ }
+ else {
+ return getStringArray("slaves", null);
+ }
+ }
+
+ /**
+ * Returns the usage of indexing volume by slave licenses in this license
+ * pool.
+ *
+ * @return A map from each slave GUID to the number of bytes it is using.
+ */
+ public Map getSlavesUsageBytes() {
+ @SuppressWarnings("unchecked")
+ HashMap values = (HashMap)get("slaves_usage_bytes");
+ if (values == null) {
+ values = new HashMap();
+ }
+
+ HashMap usageBytes = new HashMap();
+
+ for(String key : values.keySet()) {
+ String value = (String)values.get(key);
+ usageBytes.put(key, Long.parseLong(value));
+ }
+
+ return usageBytes;
+ }
+
+ /**
+ * Returns the stack ID for this license pool. Valid values are:
+ *
+ *
"download-trial"
+ *
"enterprise"
+ *
"forwarder"
+ *
"free"
+ *
+ * @return The license pool stack ID, or {@code null} if not specified.
+ */
+ public String getStackId() {
+ return getString("stack_id", null);
+ }
+
+ /**
+ * Returns the usage of indexing volume for this license pool.
+ *
+ * @return This license pool's usage, in bytes.
+ */
+ public long getUsedBytes() {
+ return getLong("used_bytes", 0);
+ }
+
+ /**
+ * Sets whether to append or overwrite slaves to this license pool.
+ *
+ * @param appendSlaves {@code true} to append slaves, {@code false} to
+ * overwrite slaves.
+ */
+ public void setAppendSlaves(boolean appendSlaves) {
+ setCacheValue("append_slaves", appendSlaves);
+ }
+
+ /**
+ * Sets the description of this license pool.
+ *
+ * @param description The description.
+ */
+ public void setDescription(String description) {
+ setCacheValue("description", description);
+ }
+
+ /**
+ * Sets the byte quota of this license pool.
+ *
+ * @param quota The indexing quota of this license pool, specified as:
+ *
number
+ *
number followed by "MB" or "GB" (for example, "10GB")
+ *
"MAX" (Only one license pool can have "MAX" size in a stack.)
+ *
+ */
+ public void setQuota(String quota) {
+ setCacheValue("quota", quota);
+ }
+
+ /**
+ * Sets the list of slaves that are members of this license pool.
+ *
+ * @param slaves The comma-separated list of slaves. Use an asterisk ("*")
+ * to accept all slaves.
+ */
+ public void setSlaves(String slaves) {
+ setCacheValue("slaves", slaves);
+ }
+
+ /**
+ * Sets the list of slaves that are members of this license pool.
+ *
+ * @param slaves The array of slaves. To accept all slaves, use an
+ * array with a single asterisk element ("*").
+ */
+ public void setSlaves(String[] slaves) {
+ setSlaves(Util.join(",", slaves));
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/LicensePoolCollection.java b/splunk/src/main/java/com/splunk/LicensePoolCollection.java
new file mode 100644
index 00000000..85668dfa
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/LicensePoolCollection.java
@@ -0,0 +1,83 @@
+/*
+ * 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.Map;
+
+/**
+ * The {@code LicensePoolCollection} class represents a collection of license
+ * pools.
+ */
+public class LicensePoolCollection extends EntityCollection {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ LicensePoolCollection(Service service) {
+ super(service, "licenser/pools", LicensePool.class);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them. See {@link CollectionArgs}.
+ */
+ LicensePoolCollection(Service service, Args args) {
+ super(service, "licenser/pools", LicensePool.class, args);
+ }
+
+ /**
+ * Creates a license pool.
+ *
+ * @param name The name of the new license pool.
+ * @param quota The indexing quota of this license pool, specified as:
+ *
number
+ *
number followed by "MB" or "GB" (for example, "10GB")
+ *
"MAX" (Only one license pool can have "MAX" size in a stack.)
+ *
+ * @param stackId The stack ID corresponding to this license pool.
+ * @return The new license pool.
+ */
+ public LicensePool create(String name, String quota, String stackId) {
+ return create(name, quota, stackId, null);
+ }
+
+ /**
+ * Creates a license pool.
+ *
+ * @param name The name of the new license pool.
+ * @param quota The indexing quota of this license pool, specified as:
+ *
number
+ *
number followed by "MB" or "GB" (for example, "10GB")
+ *
"MAX" (Only one license pool can have "MAX" size in a stack.)
+ *
+ * @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);
+ }
+}
diff --git a/splunk/com/splunk/LicenseSlave.java b/splunk/src/main/java/com/splunk/LicenseSlave.java
similarity index 64%
rename from splunk/com/splunk/LicenseSlave.java
rename to splunk/src/main/java/com/splunk/LicenseSlave.java
index ec45f182..38175ed4 100644
--- a/splunk/com/splunk/LicenseSlave.java
+++ b/splunk/src/main/java/com/splunk/LicenseSlave.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,16 @@
package com.splunk;
/**
- * Representation of a license slave.
+ * The {@code LicenseSlave} class represents a license slave, which is a member
+ * of one or more license pools. The access a license slave has to license
+ * volume is controlled by its license master.
*/
public class LicenseSlave extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The license slave endpoint.
*/
LicenseSlave(Service service, String path) {
@@ -32,27 +34,27 @@ public class LicenseSlave extends Entity {
}
/**
- * Returns this license slave's label, or null if not specified.
+ * Returns the label for this license slave.
*
- * @return This license slave's label.
+ * @return The label, or {@code null} if not specified.
*/
public String getLabel() {
return getString("label", null);
}
/**
- * Returns this license slave's list of pool IDs.
+ * Returns a list of pool IDs for this license slave.
*
- * @return This license slave's list of pool IDs.
+ * @return The list of pool IDs.
*/
public String[] getPoolIds() {
return getStringArray("pool_ids");
}
/**
- * Returns this license slave's list of stack IDs.
+ * Returns a list of stack IDs for this license pool.
*
- * @return This license slave's list of stack IDs.
+ * @return The list of stack IDs.
*/
public String[] getStackIds() {
return getStringArray("stack_ids");
diff --git a/splunk/com/splunk/LicenseStack.java b/splunk/src/main/java/com/splunk/LicenseStack.java
similarity index 63%
rename from splunk/com/splunk/LicenseStack.java
rename to splunk/src/main/java/com/splunk/LicenseStack.java
index b572e3b0..3420b329 100644
--- a/splunk/com/splunk/LicenseStack.java
+++ b/splunk/src/main/java/com/splunk/LicenseStack.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,15 @@
package com.splunk;
/**
- * Representation of a license stack.
+ * The {@code LicenseStack} class represents a license stack, which is
+ * a collection of licenses of the same type.
*/
public class LicenseStack extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The license stack endpoint.
*/
LicenseStack(Service service, String path) {
@@ -32,27 +33,28 @@ public class LicenseStack extends Entity {
}
/**
- * Returns this license stack's label, or null if not specified.
+ * Returns the label of this license stack.
*
- * @return This license stack's label.
+ * @return This license stack's label, or {@code null} if not specified.
*/
public String getLabel() {
return getString("label", null);
}
/**
- * Returns this license stack's daily indexing quota.
+ * Returns the combined daily indexing quota for all of the licenses
+ * in this license stack.
*
- * @return This license stack's daily indexing quota.
+ * @return The daily indexing quota, in bytes.
*/
public long getQuota() {
return getByteCount("quota", 0);
}
/**
- * Returns this license stack's type.
+ * Returns the license type of the licenses in this license stack.
*
- * @return This license stack's type.
+ * @return The license type.
*/
public String getType() {
return getString("type");
diff --git a/splunk/src/main/java/com/splunk/LimitPivotFilter.java b/splunk/src/main/java/com/splunk/LimitPivotFilter.java
new file mode 100644
index 00000000..dd4b89a0
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/LimitPivotFilter.java
@@ -0,0 +1,111 @@
+package com.splunk;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Represents a limit on the events shown in a pivot by sorting them according to some field, then taking
+ * the specified number from the beginning or end of the list.
+ */
+public class LimitPivotFilter extends PivotFilter {
+ private final StatsFunction statsFunction;
+ private final String sortAttribute;
+ private final int limit;
+ private final SortDirection sortDirection;
+
+ /**
+ * Throws IllegalArgumentException if statsFunction is not one of
+ * - COUNT, DISTINCT_COUNT (for fields of type string)
+ * - COUNT, DISTINCT_COUNT, SUM, AVERAGE (for fields of type number)
+ * - COUNT (for fields of type object count)
+ */
+ LimitPivotFilter(DataModelObject dataModelObject, String fieldName, String sortAttribute,
+ SortDirection sortDirection, int limit,
+ StatsFunction statsFunction) {
+ super(dataModelObject, fieldName);
+ FieldType type = dataModelObject.getField(fieldName).getType();
+ if (type != FieldType.NUMBER && type != FieldType.STRING && type != FieldType.OBJECTCOUNT) {
+ throw new IllegalArgumentException("Field " + fieldName + " on the data model object was of type "
+ + dataModelObject.getField(fieldName).getType().toString() + ", expected number, string, " +
+ "or object count.");
+ }
+ this.sortAttribute = sortAttribute;
+ this.sortDirection = sortDirection;
+ this.limit = limit;
+
+ if (type == FieldType.STRING && statsFunction != StatsFunction.COUNT &&
+ statsFunction != StatsFunction.DISTINCT_COUNT) {
+ throw new IllegalArgumentException("Stats function for fields of type string must be COUNT or " +
+ "DISTINCT_COUNT; found " + statsFunction.toString());
+ }
+ if (type == FieldType.NUMBER && statsFunction != StatsFunction.COUNT &&
+ statsFunction != StatsFunction.DISTINCT_COUNT && statsFunction != StatsFunction.SUM &&
+ statsFunction != StatsFunction.AVERAGE) {
+ throw new IllegalArgumentException("Stats function for fields of type number must be one of COUNT, " +
+ "DISTINCT_COUNT, SUM, or AVERAGE; found " + statsFunction.toString());
+ }
+ if (type == FieldType.OBJECTCOUNT && statsFunction != StatsFunction.COUNT) {
+ throw new IllegalArgumentException("Stats function for fields of type object count must be COUNT; " +
+ "found " + statsFunction.toString());
+ }
+ this.statsFunction = statsFunction;
+ }
+
+ /**
+ * Return the name of the field to use for sorting.
+ * @return String value
+ */
+ public String getAttributeName() {
+ return this.sortAttribute;
+ }
+
+ /**
+ * @return a list of the names of DataModelObjects from the most remote ancestor that is
+ * not a built-in parent to this data model object.
+ */
+ public String[] getAttributeOwnerLineage() {
+ return this.dataModelObject.getField(this.sortAttribute).getOwnerLineage();
+ }
+
+ /**
+ * @return whether the limit takes the lowest (SortDirection.ASCENDING) or highest (SortDirection.DESCENDING)
+ * values from the sorted list.
+ */
+ public SortDirection getSortDirection() {
+ return this.sortDirection;
+ }
+
+ /**
+ * @return The number of values from the sorted list to allow through this filter.
+ */
+ public int getLimit() {
+ return this.limit;
+ }
+
+ /**
+ * @return The stats function to use for aggregation before sorting.
+ */
+ public StatsFunction getStatsFunction() {
+ return this.statsFunction;
+ }
+
+ @Override
+ JsonElement toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+
+ root.add("attributeName", new JsonPrimitive(this.getAttributeName()));
+ root.add("attributeOwner", new JsonPrimitive(Util.join(".", this.getAttributeOwnerLineage())));
+ if (sortDirection == SortDirection.ASCENDING) {
+ root.add("limitType", new JsonPrimitive("lowest"));
+ } else if (sortDirection == SortDirection.DESCENDING) {
+ root.add("limitType", new JsonPrimitive("highest"));
+ }
+ root.add("limitAmount", new JsonPrimitive(this.limit));
+ root.add("statsFn", new JsonPrimitive(this.statsFunction.toString()));
+
+ return root;
+ }
+}
diff --git a/splunk/com/splunk/Logger.java b/splunk/src/main/java/com/splunk/Logger.java
similarity index 58%
rename from splunk/com/splunk/Logger.java
rename to splunk/src/main/java/com/splunk/Logger.java
index 35228011..4adf097f 100644
--- a/splunk/com/splunk/Logger.java
+++ b/splunk/src/main/java/com/splunk/Logger.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,14 @@
package com.splunk;
/**
- * Representation of a logger.
+ * The {@code Logger} class represents a specific Splunkd logging category.
*/
public class Logger extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The logger endpoint.
*/
Logger(Service service, String path) {
@@ -32,13 +32,23 @@ public class Logger extends Entity {
}
/**
- * Returns this logger's logging level. Valid values are in the set FATAL,
- * CRIT, WARN, INFO, and DEBUG.
+ * Returns the logging level of this logger. Valid values are: "FATAL",
+ * "CRIT", "WARN", "INFO", and "DEBUG".
*
- * @return This logger's logging level.
+ * @return The logging level.
*/
public String getLevel() {
return getString("level");
}
+
+ /**
+ * Sets the logging level of this logger. Valid values are: "FATAL",
+ * "CRIT", "WARN", "INFO", and "DEBUG".
+ *
+ * @param level The logging level.
+ */
+ public void setLevel(String level) {
+ setCacheValue("level", level);
+ }
}
diff --git a/splunk/src/main/java/com/splunk/LookupDataModelCalculation.java b/splunk/src/main/java/com/splunk/LookupDataModelCalculation.java
new file mode 100644
index 00000000..6aec4a86
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/LookupDataModelCalculation.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2014 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.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a lookup calculation on a data model object.
+ *
+ * A lookup calculation takes the value of an input field and uses it to
+ * look up new values for the output fields in a lookup.
+ */
+public class LookupDataModelCalculation extends DataModelCalculation {
+ private final List inputFieldMappings;
+ private final String lookupName;
+
+ public static class LookupFieldMapping {
+ public String inputField;
+ public String lookupField;
+ }
+
+ LookupDataModelCalculation(String[] ownerLineage, String calculationID,
+ Map generatedFields, String comment,
+ boolean editable, String lookupName,
+ List inputFieldMappings) {
+ super(ownerLineage, calculationID, generatedFields, comment, editable);
+ this.lookupName = lookupName;
+ this.inputFieldMappings = inputFieldMappings;
+ }
+
+ /**
+ * @return the name of the lookup to use
+ */
+ public String getLookupName() { return this.lookupName; }
+
+ /**
+ * @return the mappings from fields in the events to fields in the lookup
+ */
+ public List getInputFieldMappings() {
+ return Collections.unmodifiableList(this.inputFieldMappings);
+ }
+}
diff --git a/splunk/com/splunk/Message.java b/splunk/src/main/java/com/splunk/Message.java
similarity index 66%
rename from splunk/com/splunk/Message.java
rename to splunk/src/main/java/com/splunk/Message.java
index 838e5651..656a85ed 100644
--- a/splunk/com/splunk/Message.java
+++ b/splunk/src/main/java/com/splunk/Message.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,16 @@
package com.splunk;
/**
- * Representation of a message.
+ * The {@code Message} class represents a message. Most messages are created by
+ * Splunkd to inform the user of system problems, such as license quotas,
+ * license expirations, misconfigured indexes, and disk space.
*/
public class Message extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The message endpoint.
*/
Message(Service service, String path) {
@@ -32,18 +34,18 @@ public class Message extends Entity {
}
/**
- * Returns this message's title.
+ * Returns the title of this message.
*
- * @return This message's title.
+ * @return The message title.
*/
public String getKey() {
return getTitle();
}
/**
- * Returns this message's value.
+ * Returns the content of this message.
*
- * @return This message's value.
+ * @return The message text.
*/
public String getValue() {
return getString(getKey());
diff --git a/splunk/com/splunk/MessageCollection.java b/splunk/src/main/java/com/splunk/MessageCollection.java
similarity index 52%
rename from splunk/com/splunk/MessageCollection.java
rename to splunk/src/main/java/com/splunk/MessageCollection.java
index 36efa66a..db8c1267 100644
--- a/splunk/com/splunk/MessageCollection.java
+++ b/splunk/src/main/java/com/splunk/MessageCollection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,25 +17,38 @@
package com.splunk;
/**
- * Representation of a collection of messages.
+ * The {@code MessageCollection} class represents a collection of messages,
+ * providing access to Splunk system messages. Most messages are created by
+ * Splunkd to inform the user of system problems.
*/
public class MessageCollection extends EntityCollection {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
*/
MessageCollection(Service service) {
super(service, "messages", Message.class);
}
/**
- * Create a new message.
+ * Class constructor.
*
- * @param name The name of the new message.
- * @param value The value of the message.
- * @return The created message.
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them. See {@link CollectionArgs}.
+ */
+ MessageCollection(Service service, Args args) {
+ super(service, "messages", Message.class, args);
+ }
+
+ /**
+ * Creates a new message.
+ *
+ * @param name The name (primary key) of the new message.
+ * @param value The message text.
+ * @return The new message.
*/
public Message create(String name, String value) {
Args args = new Args("value", value);
diff --git a/splunk/src/main/java/com/splunk/ModularInputKind.java b/splunk/src/main/java/com/splunk/ModularInputKind.java
new file mode 100644
index 00000000..5cc6f2a5
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/ModularInputKind.java
@@ -0,0 +1,111 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+import java.util.List;
+
+/**
+ * The {@code ModularInputKind} class represents a particular modular input.
+ * The actual inputs of this kind can be accessed from the
+ * {@code InputCollection} object.
+ */
+public class ModularInputKind extends Entity {
+ protected Map> args;
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The entity's endpoint.
+ */
+ ModularInputKind(Service service, String path) {
+ super(service, path);
+ Map>> endpoint =
+ (Map>>)get("endpoint");
+ this.args = endpoint.get("args");
+ }
+
+ /**
+ * Returns an argument map that contains the argument names as keys, and the
+ * {@code ModularInputKindArgument}s as corresponding values.
+ *
+ * @return A {@code Map} containing the argument key-value pairs.
+ */
+ public Map getArguments() {
+ Map arguments = new HashMap();
+ for (String argumentName : args.keySet()) {
+ arguments.put(argumentName, getArgument(argumentName));
+ }
+ return arguments;
+ }
+
+ /**
+ * Returns the streaming mode of this modular input kind.
+ *
+ * @return The streaming mode ("xml" or "simple").
+ */
+ public String getStreamingMode() {
+ String mode = getString("streaming_mode");
+ return mode;
+ }
+
+ /**
+ * Returns a map-like object representing a particular argument of this
+ * modular input kind.
+ *
+ * @param argumentName The name of the argument to retrieve.
+ * @return A {@code ModularInputKindArgument} object representing the given
+ * argument, or {@code null} if the argument does not exist.
+ */
+ public ModularInputKindArgument getArgument(String argumentName) {
+ if (this.args.get(argumentName) != null) {
+ return new ModularInputKindArgument(this.args.get(argumentName));
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the description of this modular input kind.
+ *
+ * @return A string containing the description.
+ */
+ public String getDescription() {
+ return getString("description", null);
+ }
+
+ /**
+ * Returns the title of this modular input kind, which is also displayed in
+ * Splunk Web (rather than the name used in the REST API).
+ *
+ * @return A string containing the title.
+ */
+ public String getTitle() {
+ return getString("title", null);
+ }
+
+ /**
+ * Indicates whether this modular input kind has a given argument.
+ *
+ * @param argumentName The argument to look up.
+ * @return {@code true} if the argument exists, {@code false} if not.
+ */
+ public boolean hasArgument(String argumentName) {
+ return this.args.containsKey(argumentName);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/ModularInputKindArgument.java b/splunk/src/main/java/com/splunk/ModularInputKindArgument.java
new file mode 100644
index 00000000..6f42de3d
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/ModularInputKindArgument.java
@@ -0,0 +1,88 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+/**
+ * The {@code ModularInputKindArgument} class is a map-like object that is
+ * specialized to represent arguments for modular input kinds.
+ */
+public class ModularInputKindArgument extends HashMap {
+ public enum Type { NUMBER, STRING, BOOLEAN };
+
+ /**
+ * Class constructor.
+ *
+ * @param template A {@code Map<String,String>} that is copied into
+ * the new object.
+ */
+ ModularInputKindArgument(Map template) {
+ super();
+ putAll(template);
+ }
+
+ /**
+ * Returns the description of this field.
+ *
+ * @return The description.
+ */
+ public String getDescription() {
+ return get("description");
+ }
+
+ /**
+ * Indicates whether this argument is required when creating a modular input
+ * of this kind.
+ *
+ * @return {@code true} if this argument is required for creating an input,
+ * {@code false} if not.
+ */
+ public boolean getRequiredOnCreate() {
+ return Value.toBoolean(get("required_on_create"));
+ }
+
+ /**
+ * Indicates whether this argument is required when editing a modular input
+ * of this kind.
+ *
+ * @return {@code true} if this argument is required for editing,
+ * {@code false} if not.
+ */
+ public boolean getRequiredOnEdit() {
+ return Value.toBoolean(get("required_on_edit"));
+ }
+
+ /**
+ * Returns the type of this argument to the modular input.
+ *
+ * @return A member of the {@code ModularInputKindArgumentType} enumeration
+ * ({@code Number}, {@code Boolean}, or {@code String}).
+ */
+ public Type getType() {
+ String type = get("data_type");
+ if (type.equals("number")) {
+ return Type.NUMBER;
+ } else if (type.equals("boolean")) {
+ return Type.BOOLEAN;
+ } else if (type.equals("string")) {
+ return Type.STRING;
+ } else {
+ throw new IllegalStateException("Invalid data_type value: " + type);
+ }
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/MonitorInput.java b/splunk/src/main/java/com/splunk/MonitorInput.java
new file mode 100644
index 00000000..3027b6c6
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/MonitorInput.java
@@ -0,0 +1,356 @@
+/*
+ * 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;
+/**
+ * The {@code MonitorInput} class represents a monitor input, which is a file,
+ * directory, script, or network port that is monitored for new data.
+ */
+public class MonitorInput extends Input {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The monitor input endpoint.
+ */
+ MonitorInput(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns a regular expression for a file path that when matched is not
+ * indexed.
+ *
+ * @return The regex for a file path.
+ */
+ public String getBlacklist() {
+ return getString("blacklist", null);
+ }
+
+ /**
+ * Returns a string that is used to force Splunk to index files that have a
+ * matching cyclic redundancy check (CRC).
+ *
+ * When set, this string is added to the CRC. If the string is
+ * "{@code }", the full source path is added to the CRC, ensuring
+ * that each file being monitored has a unique CRC. For more info, see the
+ * Edit inputs.conf
+ * topic in the Getting Data In manual.
+ *
+ * @return The string that is added to the CRC, or {@code null} if not set.
+ */
+ public String getCrcSalt() {
+ return getString("crcSalt", null);
+ }
+
+ /**
+ * Returns the file count of this monitor input.
+ *
+ * @return The file count.
+ */
+ public int getFileCount() {
+ return getInteger("filecount", -1);
+ }
+
+ /**
+ * Indicates whether files that are seen for the first time will be read
+ * from the end.
+ *
+ * @return {@code true} if new files are read from the end, {@code false} if
+ * not.
+ */
+ public boolean getFollowTail() {
+ return getBoolean("followTail", false);
+ }
+
+ /**
+ * Returns the host for this monitor input.
+ *
+ * @return The host, or {@code null} if not specified.
+ */
+ public String getHost() {
+ return getString("host", null);
+ }
+
+ /**
+ * Returns the regular expression for a file path to determine the host.
+ * If the path for a file matches this regular expression, the captured
+ * value is used to populate the host field for events from this
+ * monitor input. The regular expression must have one capture group.
+ *
+ * @return The regular expression for a file path.
+ */
+ public String getHostRegex() {
+ return getString("host_regex", null);
+ }
+
+ /**
+ * Returns a time value that defines a rolling time window for monitoring
+ * files. If the modification time of a file being monitored falls outside
+ * of this rolling time window, the file is no longer being monitored.
+ *
+ * @return The time value.
+ */
+ public String getIgnoreOlderThan() {
+ return getString("ignoreOlderThan", null);
+ }
+
+ /**
+ * Gets the index where events from this monitor input are stored.
+ *
+ * @return The index name.
+ */
+ public String getIndex() {
+ return getString("index");
+ }
+
+ /**
+ * Returns the type of monitor input.
+ *
+ * @return The input kind.
+ */
+ public InputKind getKind() {
+ return InputKind.Monitor;
+ }
+
+ /**
+ * Returns the queue for this monitor input. Valid values are "parsingQueue"
+ * and "indexQueue".
+ *
+ * @return The queue, or {@code null} if not specified.
+ */
+ public String getQueue() {
+ return getString("queue", null);
+ }
+
+ /**
+ * Indicates whether sub-directories are monitored within this monitor
+ * input.
+ *
+ * @return {@code true} if sub-directories are monitored, {@code false} if
+ * not.
+ */
+ public boolean getRecursive() {
+ return getBoolean("recursive", false);
+ }
+
+ /**
+ * @deprecated Returns the value of the {@code _rcvbuf} attribute for this
+ * monitor input.
+ *
+ * @return The {@code _rcvbuf} value.
+ */
+ public int getRcvBuf() {
+ return getInteger("_rcvbuf");
+ }
+
+ /**
+ * Returns the source of events from this monitor input.
+ *
+ * @return The source name.
+ */
+ public String getSource() {
+ return getString("source", null);
+ }
+
+ /**
+ * Returns the source type of events from this monitor input.
+ *
+ * @return The source type.
+ */
+ public String getSourceType() {
+ return getString("sourcetype", null);
+ }
+
+ /**
+ * Returns the time period for keeping a file open.
+ *
+ * @return The time to keep a file open, in seconds.
+ */
+ public int getTimeBeforeClose() {
+ return getInteger("time_before_close", -1);
+ }
+
+ /**
+ * Returns a regular expression for a file path that, when matched, is
+ * indexed.
+ *
+ * @return The regular expression for a file path.
+ */
+ public String getWhitelist() {
+ return getString("whitelist", null);
+ }
+
+ /**
+ * Sets a regular expression for a file path that, when matched, is not
+ * indexed.
+ *
+ * @param blacklist The regular expression for a file path.
+ */
+ public void setBlacklist(String blacklist) {
+ setCacheValue("blacklist", blacklist);
+ }
+
+ /**
+ * Sets whether the {@code index} value is checked to ensure that it is the
+ * name of a valid index.
+ *
+ * @param index {@code true} to verify {@code index}, {@code false} if not.
+ */
+ public void setCheckIndex(boolean index) {
+ setCacheValue("check-index", index);
+ }
+
+ /**
+ * Sets whether the {@code name} value is checked to ensure that it exists.
+ *
+ * @param path {@code true} to verify {@code name}, {@code false} if not.
+ */
+ public void setCheckPath(boolean path) {
+ setCacheValue("check-path", path);
+ }
+
+ /**
+ * Sets a string that is used to force Splunk to index files that have a
+ * matching cyclic redundancy check (CRC).
+ *
+ * When set, this string is added to the CRC. If the string is
+ * "{@code }", the full source path is added to the CRC, ensuring
+ * that each file being monitored has a unique CRC. For more info, see the
+ * Edit inputs.conf
+ * topic in the Getting Data In manual.
+ *
+ * @param salt The string that is added to the CRC.
+ */
+ public void setCrcSalt(String salt) {
+ setCacheValue("crc-salt", salt);
+ }
+
+ /**
+ * Sets whether files that are seen for the first time will be read from
+ * the end.
+ *
+ * @param followTail {@code true} to read new files from the end,
+ * {@code false} if not.
+ */
+ public void setFollowTail(boolean followTail) {
+ setCacheValue("followTail", followTail);
+ }
+
+ /**
+ * Sets the value to populate in the host field for events from this
+ * monitor input.
+ *
+ * @param host The value for the host field.
+ */
+ public void setHost(String host) {
+ setCacheValue("host", host);
+ }
+
+ /**
+ * Set the regular expression for a file path to determine the host.
+ * If the path for a file matches this regular expression, the captured
+ * value is used to populate the host field for events from this
+ * monitor input. The regular expression must have one capture group.
+ *
+ * @param regex The regular expression for a file path.
+ */
+ public void setHostRegex(String regex) {
+ setCacheValue("host_regex", regex);
+ }
+
+ /**
+ * Sets the specified slash-separate segment of the file path as the
+ * host field value.
+ *
+ * @param segment The slash-separate segment.
+ */
+ public void setHostSegment(String segment) {
+ setCacheValue("host_segment", segment);
+ }
+
+ /**
+ * Sets a time value that defines a rolling time window for monitoring
+ * files. If the modification time of a file being monitored falls outside
+ * of this rolling time window, the file is no longer being monitored.
+ *
+ * @param time The time value.
+ */
+ public void setIgnoreOlderThan(String time) {
+ setCacheValue("ignore-older-than", time);
+ }
+
+ /**
+ * Sets the index where events from this monitor input are stored.
+ *
+ * @param index The index name.
+ */
+ public void setIndex(String index) {
+ setCacheValue("index", index);
+ }
+
+ /**
+ * Sets whether to monitor sub-directories within this monitor input.
+ *
+ * @param recursive {@code true} to monitor sub-directories, {@code false}
+ * if not.
+ */
+ public void setRecursive(boolean recursive) {
+ setCacheValue("recursive", recursive);
+ }
+
+ /**
+ * Sets the name to populate in the source field for events
+ * from this monitor input. The same source name should not be used for
+ * multiple data inputs.
+ *
+ * @param name The source name.
+ */
+ public void setRenameSource(String name) {
+ setCacheValue("rename-source", name);
+ }
+
+ /**
+ * Sets the source type to populate in the sourcetype field for
+ * events from this monitor input.
+ *
+ * @param sourcetype The source type.
+ */
+ public void setSourcetype(String sourcetype) {
+ setCacheValue("sourcetype", sourcetype);
+ }
+
+ /**
+ * Sets the time period for keeping a file open.
+ *
+ * @param period The time to keep a file open, in seconds.
+ */
+ public void setTimeBeforeClose(int period) {
+ setCacheValue("time-before-close", period);
+ }
+
+ /**
+ * Sets a regular expression for a file path that, when matched, is indexed.
+ *
+ * @param whitelist The regular expression for the file path.
+ */
+ public void setWhitelist(String whitelist) {
+ setCacheValue("whitelist", whitelist);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/MultiResultsReader.java b/splunk/src/main/java/com/splunk/MultiResultsReader.java
new file mode 100644
index 00000000..cc57b97f
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/MultiResultsReader.java
@@ -0,0 +1,63 @@
+/*
+ * 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.util.Iterator;
+
+/**
+ * The {@code MultiResultsReader} class represents a streaming reader
+ * for Splunk search results. Using {@code } allows
+ * specialization of {@code T} in subclasses of {@code MultiResultsReader}, such
+ * as {@link MultiResultsReaderXml} and {@link MultiResultsReaderJson}.
+ */
+public class MultiResultsReader
+ extends StreamIterableBase {
+ private T resultsReader;
+
+ MultiResultsReader(T resultsReader) throws IOException {
+ this.resultsReader = resultsReader;
+ }
+
+ /**
+ * Returns an iterator over the sets of results from this reader.
+ * @return An iterator.
+ */
+ @Override
+ public final Iterator iterator() {
+ return super.iterator();
+ }
+
+ /**
+ * Closes the reader and releases resources.
+ * @throws IOException If reader is not closed.
+ */
+ public final void close() throws IOException {
+ resultsReader.close();
+ }
+
+ protected final T getNextElement() {
+ try {
+ if (!resultsReader.resetIteratorToNextSet()) {
+ return null;
+ }
+ return resultsReader;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/splunk/src/main/java/com/splunk/MultiResultsReaderJson.java b/splunk/src/main/java/com/splunk/MultiResultsReaderJson.java
new file mode 100644
index 00000000..77a2c9f6
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/MultiResultsReaderJson.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+/**
+ * The {@code MultiResultsReaderJson} class represents a streaming JSON reader
+ * for Splunk search results. This reader supports streams from export searches,
+ * which might return one of more previews before returning final results.
+ */
+public class MultiResultsReaderJson
+ extends MultiResultsReader {
+ /**
+ * Class constructor.
+ *
+ * Constructs a streaming JSON reader for the event stream. You should only
+ * attempt to parse a JSON stream with this reader. Unpredictable results
+ * may occur if you try to parse a stream with a different format.
+ *
+ * @param inputStream The JSON stream to parse.
+ * @throws IOException The IOException instance
+ */
+ public MultiResultsReaderJson(InputStream inputStream) throws IOException {
+ super(new ResultsReaderJson(inputStream, true));
+ }
+}
\ No newline at end of file
diff --git a/splunk/src/main/java/com/splunk/MultiResultsReaderXml.java b/splunk/src/main/java/com/splunk/MultiResultsReaderXml.java
new file mode 100644
index 00000000..53088389
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/MultiResultsReaderXml.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+/**
+ * The {@code MultiResultsReaderXml} class represents a streaming XML reader for
+ * Splunk search results. This reader supports streams from export searches,
+ * which might return one of more previews before returning final results.
+ */
+public class MultiResultsReaderXml
+ extends MultiResultsReader {
+ /**
+ * Class constructor.
+ *
+ * Constructs a streaming XML reader for the event stream. You should only
+ * attempt to parse an XML stream with this reader. Unpredictable results
+ * may occur if you try to parse a stream with a different format.
+ *
+ * @param inputStream The XML stream to parse.
+ * @throws IOException The IOException instance
+ */
+ public MultiResultsReaderXml(InputStream inputStream) throws IOException {
+ super(new ResultsReaderXml(inputStream, true));
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/NumberComparison.java b/splunk/src/main/java/com/splunk/NumberComparison.java
new file mode 100644
index 00000000..c58b48db
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/NumberComparison.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2014 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;
+
+/**
+ * Comparison operators on numeric fields.
+ */
+public enum NumberComparison {
+ EQUALS {
+ public String toString() { return "="; }
+ },
+ NOT_EQUALS {
+ public String toString() { return "!="; }
+ },
+ LESS_THAN {
+ public String toString() { return "<"; }
+ },
+ AT_MOST {
+ public String toString() { return "<="; }
+ },
+ GREATHER_THAN {
+ public String toString() { return ">"; }
+ },
+ AT_LEAST {
+ public String toString() { return ">="; }
+ },
+ IS_NULL {
+ public String toString() { return "isNull"; }
+ },
+ IS_NOT_NULL {
+ public String toString() { return "isNotNull"; }
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/NumberPivotFilter.java b/splunk/src/main/java/com/splunk/NumberPivotFilter.java
new file mode 100644
index 00000000..6b0a42f3
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/NumberPivotFilter.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Specifies a filter in a pivot on a numeric field.
+ */
+public class NumberPivotFilter extends PivotFilter {
+ private final NumberComparison comparison;
+ private final double comparisonValue;
+
+ NumberPivotFilter(DataModelObject dataModelObject, String field,
+ NumberComparison comparison, double comparisonValue) {
+ super(dataModelObject, field);
+ if (dataModelObject.getField(field).getType() != FieldType.NUMBER) {
+ throw new IllegalArgumentException("Field " + field + " on the data model object was of type "
+ + dataModelObject.getField(field).getType().toString() + ", expected number.");
+ }
+ this.comparison = comparison;
+ this.comparisonValue = comparisonValue;
+ }
+
+ @Override
+ JsonElement toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+
+ JsonObject filterRule = new JsonObject();
+ filterRule.add("comparator", new JsonPrimitive(this.comparison.toString()));
+ filterRule.add("compareTo", new JsonPrimitive(this.comparisonValue));
+
+ root.add("rule", filterRule);
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/NumberPivotRowSplit.java b/splunk/src/main/java/com/splunk/NumberPivotRowSplit.java
new file mode 100644
index 00000000..69118602
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/NumberPivotRowSplit.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Specifies a row split in a pivot on a numeric field.
+ *
+ * Each value of the field will be split into a different row.
+ */
+public class NumberPivotRowSplit extends PivotRowSplit {
+ NumberPivotRowSplit(DataModelObject owner, String field, String label) {
+ super(owner, field, label);
+ }
+
+ @Override
+ JsonElement toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+ root.add("display", new JsonPrimitive("all"));
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/NumericPivotColumnSplit.java b/splunk/src/main/java/com/splunk/NumericPivotColumnSplit.java
new file mode 100644
index 00000000..61aade19
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/NumericPivotColumnSplit.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+public class NumericPivotColumnSplit extends PivotColumnSplit {
+ NumericPivotColumnSplit(DataModelObject dataModelObject, String field) {
+ super(dataModelObject, field);
+ }
+
+ @Override
+ JsonObject toJson() {
+ JsonObject root = new JsonObject();
+
+ addCommonFields(root);
+ root.add("display", new JsonPrimitive("all"));
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/OutputDefault.java b/splunk/src/main/java/com/splunk/OutputDefault.java
new file mode 100644
index 00000000..abd9733f
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/OutputDefault.java
@@ -0,0 +1,319 @@
+/*
+ * 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.Map;
+
+/**
+ * The {@code OutputDefault} class represents the default TCP output
+ * configuration, providing access to global TCP output properties.
+ */
+public class OutputDefault extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ OutputDefault(Service service) {
+ super(service, "data/outputs/tcp/default");
+ }
+
+ /**
+ * Indicates whether this forwarder performs automatic load balancing.
+ * When {@code true}, this forwarder selects a new indexer using the
+ * frequency specified by {@code autoLBFrequency}, or immediately when an
+ * open connection to an indexer is lost.
+ *
+ * @see #getAutoLBFrequency
+ *
+ * @return {@code true} if this forwarder performs automatic load balancing,
+ * {@code false} if not.
+ */
+ public boolean getAutoLB() {
+ return getBoolean("autoLB", false);
+ }
+
+ /**
+ * Indicates whether this forwarder blocks when the output queue is full.
+ * Blocking causes further blocking up the processing chain--if any target
+ * group's queue is blocked, no more data reaches any other target group.
+ * When {@code false}, events are dropped when indexers in the group
+ * can't be reached.
+ *
+ * @return {@code true} if this forwarder will block, {@code false} if not.
+ */
+ public boolean blockOnQueueFull() {
+ return getBoolean("blockOnQueueFull", true);
+ }
+
+ /**
+ * Returns the frequency of automatic load balancing.
+ *
+ * @return The automatic load-balancing frequency in seconds, or -1 if not
+ * specified.
+ */
+ public int getAutoLBFrequency() {
+ return getInteger("autoLBFrequency", -1);
+ }
+
+ /**
+ * Returns the amount of time this forwarder waits before dropping
+ * events if the output queue is full. A setting of 0 or -1 causes this
+ * forwarder to block.
+ *
+ * @return The wait time, in seconds.
+ */
+ public int getDropEventsOnQueueFull() {
+ return getInteger("dropEventsOnQueueFull", -1);
+ }
+
+ /**
+ * Returns the inclusive set of indexes (whitelist 0) for this forwarder.
+ * This is an ordered list of whitelists and blacklists, which together
+ * decide if events should be forwarded to an index.
+ *
+ * @return The inclusive set of indexes.
+ */
+ public String getForwardedIndex0Whitelist() {
+ return getString("forwardedindex.0.whitelist");
+ }
+
+ /**
+ * Returns the exclusive set of indexes (blacklist 1) for this forwarder.
+ * This is an ordered list of whitelists and blacklists, which together
+ * decide if events should be forwarded to an index.
+ *
+ * @return The exclusive set of indexes.
+ */
+ public String getForwardedIndex1Blacklist() {
+ return getString("forwardedindex.1.blacklist");
+ }
+
+ /**
+ * Returns the inclusive set of indexes (whitelist 2) for this forwarder.
+ * This is an ordered list of whitelists and blacklists, which together
+ * decide if events should be forwarded to an index.
+ *
+ * @return The inclusive set of indexes.
+ */
+ public String getForwardedIndex2Whitelist() {
+ return getString("forwardedindex.2.whitelist");
+ }
+
+ /**
+ * Returns the frequency that specifies how often to send a heartbeat packet
+ * to the receiving server.
+ *
+ * Note: This field is only used when {@code SendCookedData} is
+ * {@code true}.
+ *
+ * @see #getSendCookedData
+ * @see #setSendCookedData
+ * @return The heartbeat frequency, in seconds.
+ */
+ public int getHeartbeatFrequency() {
+ return getInteger("heartbeatFrequency", 30);
+ }
+
+ /**
+ * Returns the maximum size of the output queue for this forwarder.
+ * The maximum size of the wait queue is set to three times this value.
+ *
+ * @return The maximum size of the output queue. The string maybe "auto" or a number followed by one of the suffixes
+ * "B", "KB", "MB", or "GB" (for bytes, kilobytes, megabytes, and gigabytes, respectively).
+ */
+ public String getMaxQueueSize() {
+ return getString("maxQueueSize");
+ }
+
+ /**
+ * Indicates whether Splunk has processed ("cooked") the event data.
+ *
+ * @return {@code true} if the event data has been processed, {@code false}
+ * if not.
+ */
+ public boolean getSendCookedData() {
+ return getBoolean("sendCookedData", true);
+ }
+
+ /**
+ * Indicates whether to index data locally in addition to forwarding it.
+ *
+ * Note: This setting is not available for light forwarders.
+ *
+ * @return {@code true} if data is indexed locally and forwarded,
+ * {@code false} if not.
+ */
+ public boolean indexAndForward() {
+ return getBoolean("indexAndForward", false);
+ }
+
+ /**
+ * Indicates whether this forwarder sends compressed data.
+ *
+ * @return {@code true} if this forwarder sends compressed data,
+ * {@code false} if not.
+ */
+ public boolean isCompressed() {
+ return getBoolean("compressed", false);
+ }
+
+ @Override
+ protected boolean isNameChangeAllowed() {
+ // The "name" property is actually required by the underlying POST
+ // request that update() uses
+ return true;
+ }
+
+ /**
+ * Indicates whether the index filter for this forwarder is disabled.
+ *
+ * @return {@code true} if the index filter is disabled, {@code false}
+ * if events are raw and untouched before sending.
+ */
+ public boolean isForwardedIndexFilterDisable() {
+ return getBoolean("forwardedindex.filter.disable");
+ }
+
+ /**
+ * Sets how long to wait before throwing out all new events until the output
+ * queue has space. The default value is -1, which means to not drop events.
+ *
+ * Caution: Do not set this value to a positive integer if you are
+ * monitoring files.
+ *
+ * Setting this to -1 or 0 causes the output queue to block when it gets
+ * full, which causes further blocking up the processing chain. If any
+ * target group's queue is blocked, no more data reaches any other target
+ * group.
+ *
+ * Using auto load-balancing is the best way to minimize this condition,
+ * because, in that case, multiple receivers must be down or jammed before
+ * queue blocking can occur.
+ * @see #getAutoLB
+ *
+ * @param dropEventsOnQueueFull The time to wait before throwing out events,
+ * in seconds, or -1 to not drop events.
+ */
+ public void setDropEventsOnQueueFull(int dropEventsOnQueueFull) {
+ setCacheValue("dropEventsOnQueueFull", dropEventsOnQueueFull);
+ }
+
+ /**
+ * Sets the frequency between heartbeat packets that are sent to the
+ * receiving server.
+ *
+ * Note: Heartbeats are only sent when {@code SendCookedData} is
+ * {@code true}.
+ * @see #getSendCookedData
+ * @see #setSendCookedData
+ *
+ * @param frequency The frequency, in seconds.
+ */
+ public void setHeartbeatFrequency(int frequency) {
+ setCacheValue("heartbeatFrequency", frequency);
+ }
+
+ /**
+ * Sets whether to index all data locally, in addition to forwarding it.
+ *
+ * This configuration is known as "index-and-forward". This attribute is
+ * only available for heavy forwarders, at the top-level {@code [tcpout]}
+ * stanza in outputs.conf. It cannot be overridden in a target group.
+ *
+ * @param indexAndForward {@code true} to index and forward data,
+ * {@code false} to forward only.
+ */
+ public void setIndexAndForward(boolean indexAndForward) {
+ setCacheValue("indexAndForward", indexAndForward);
+ }
+
+ /**
+ * Sets the maximum size of the forwarder's output queue. This value also
+ * sets the maximum size of the wait queue to three times this
+ * value, if you have enabled indexer acknowledgment (the {@code useACK}
+ * attribute is set to {@code true} in the forwarder's outputs.conf).
+ *
+ * Although the wait queue and the output queues are both configured by
+ * this attribute, they are separate queues. The setting determines the
+ * maximum size of the queue's in-memory (RAM) buffer.
+ *
+ * For heavy forwarders that send parsed data, {@code maxQueueSize} is the
+ * maximum number of events. Because events are typically much shorter than
+ * data blocks, the memory consumed by the queue on a parsing forwarder will
+ * likely be much smaller than on a non-parsing forwarder, if you use this
+ * version of the setting.
+ *
+ * If you specify an integer (for example, "100"), {@code maxQueueSize}
+ * indicates the maximum number of queued events (for parsed data) or blocks
+ * of data (for unparsed data). A block of data is approximately 64KB. For
+ * non-parsing forwarders that send unparsed data, such as universal
+ * forwarders, {@code maxQueueSize} is the maximum number of data blocks.
+ *
+ * If specified as an integer followed by "KB", MB", or "GB" (for example,
+ * "100MB"), {@code maxQueueSize} indicates the maximum RAM allocated
+ * to the queue buffer. The default is 500KB (which means a maximum size of
+ * 500KB for the output queue and 1500KB for the wait queue, if any).
+ *
+ * @param maxQueueSize The maximum queue size as a number, or a number
+ * followed by "KB", MB", or "GB".
+ */
+ public void setMaxQueueSize(String maxQueueSize) {
+ setCacheValue("maxQueueSize", maxQueueSize);
+ }
+
+ /**
+ * Sets the name. Only "tcpout" is valid.
+ */
+ public void setName() {
+ setCacheValue("name", "tcpout");
+ }
+
+ /**
+ * Sets whether to forward cooked data.
+ *
+ * @param sendCookedData {@code true} for Splunk to process events before
+ * sending them, {@code false} to send raw and untouched events.
+ */
+ public void setSendCookedData(boolean sendCookedData) {
+ setCacheValue("sendCookedData", sendCookedData);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public void update(Map args) {
+ // Add required arguments if not already present
+ if (!args.containsKey("name")) {
+ args = Args.create(args).add("name", "tcpout");
+ }
+ super.update(args);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public void update() {
+ // If not present in the update keys, add required attribute as long
+ // as one pre-existing update pair exists
+ if (toUpdate.size() > 0 && !toUpdate.containsKey("name")) {
+ setCacheValue("name", "tcpout");
+ }
+ super.update();
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/OutputGroup.java b/splunk/src/main/java/com/splunk/OutputGroup.java
new file mode 100644
index 00000000..66f8653c
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/OutputGroup.java
@@ -0,0 +1,226 @@
+/*
+ * 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.Map;
+
+/**
+ * The {@code OutputGroup} class represents an output group, providing
+ * access to the configuration of a group of one or more data-forwarding
+ * destinations.
+ */
+public class OutputGroup extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The output group endpoint.
+ */
+ OutputGroup(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Indicates whether this forwarder performs automatic load balancing.
+ *
+ * @return {@code true} if the forwarder performs automatic load balancing,
+ * {@code false} if not.
+ */
+ public boolean getAutoLB() {
+ return getBoolean("autoLB", false);
+ }
+
+ /**
+ * Returns the type of output processor for this forwarder group.
+ * Valid values are: "tcpout", "syslog", and "httpout".
+ *
+ * @return The output processor type, or {@code null} if not specified.
+ */
+ public String getMethod() {
+ return getString("method", null);
+ }
+
+ /**
+ * Returns the list of servers for this forwarder group.
+ *
+ * @return The server list.
+ */
+ public String[] getServers() {
+ return getString("servers").split(",");
+ }
+
+ /**
+ * Sets the list of servers included in this group.
+ *
+ * @param servers A comma-separated list of servers.
+ */
+ public void setServers(String servers) {
+ setCacheValue("servers", servers);
+ }
+
+ /**
+ * Sets whether this forwarder performs automatic load balancing.
+ *
+ * If set to {@code true}, the forwarder performs automatic load balancing.
+ * In automatic mode, the forwarder selects a new indexer every
+ * {@code autoLBFrequency} seconds. If the connection to the current
+ * indexer is lost, the forwarder selects a new live indexer to forward
+ * data to.
+ *
+ * Do not change the default setting, unless you have some overriding need
+ * to use round-robin load balancing. Round-robin load balancing
+ * ({@code autoLB} is {@code false}) was previously the default
+ * load-balancing method. Starting with release 4.2, however, round-robin
+ * load balancing has been deprecated, and the default has been changed to
+ * automatic load balancing ({@code autoLB} is {@code true}).
+ * @see #getAutoLB
+ * @see OutputDefault#getAutoLBFrequency
+ *
+ * @param autoLB {@code true} to perform automatic load balancing on this
+ * forwarder, {@code false} if not.
+ */
+ public void setAutoLB(boolean autoLB) {
+ setCacheValue("autoLB", autoLB);
+ }
+
+ /**
+ * Sets whether this forwarder sends compressed data. The receiver port must
+ * also have compression enabled for this to work.
+ *
+ * @param compressed {@code true} for this forwarder to send compressed
+ * data, {@code false} if not.
+ */
+ public void setCompressed(boolean compressed) {
+ setCacheValue("compressed", compressed);
+ }
+
+ /**
+ * Sets how long to wait before throwing out all new events until the output
+ * queue has space. The default value is -1, which means to not drop events.
+ *
+ * Caution: Do not set this value to a positive integer if you are
+ * monitoring files.
+ *
+ * Setting this to -1 or 0 causes the output queue to block when it gets
+ * full, which causes further blocking up the processing chain. If any
+ * target group's queue is blocked, no more data reaches any other target
+ * group.
+ *
+ * Using auto load-balancing is the best way to minimize this condition,
+ * because, in that case, multiple receivers must be down or jammed before
+ * queue blocking can occur.
+ * @see #getAutoLB
+ *
+ * @param dropEventsOnQueueFull The time to wait before throwing out events,
+ * in seconds, or -1 to not drop events.
+ */
+ public void setDropEventsOnQueueFull(int dropEventsOnQueueFull) {
+ setCacheValue("dropEventsOnQueueFull", dropEventsOnQueueFull);
+ }
+
+ /**
+ * Sets the frequency between heartbeat packets that are sent to the
+ * receiving server.
+ *
+ * Note: Heartbeats are only sent when {@code SendCookedData} is
+ * {@code true}.
+ * @see OutputDefault#getSendCookedData
+ *
+ * @param frequency The frequency, in seconds.
+ */
+ public void setHeartbeatFrequency(int frequency) {
+ setCacheValue("heartbeatFrequency", frequency);
+ }
+
+ /**
+ * Sets the maximum size of the forwarder's output queue. This value also
+ * sets the maximum size of the wait queue to three times this
+ * value, if you have enabled indexer acknowledgment (the {@code useACK}
+ * attribute is set to {@code true} in the forwarder's outputs.conf).
+ *
+ * Although the wait queue and the output queues are both configured by
+ * this attribute, they are separate queues. The setting determines the
+ * maximum size of the queue's in-memory (RAM) buffer.
+ *
+ * For heavy forwarders that send parsed data, {@code maxQueueSize} is the
+ * maximum number of events. Because events are typically much shorter than
+ * data blocks, the memory consumed by the queue on a parsing forwarder will
+ * likely be much smaller than on a non-parsing forwarder, if you use this
+ * version of the setting.
+ *
+ * If you specify an integer (for example, "100"), {@code maxQueueSize}
+ * indicates the maximum number of queued events (for parsed data) or blocks
+ * of data (for unparsed data). A block of data is approximately 64KB. For
+ * non-parsing forwarders that send unparsed data, such as universal
+ * forwarders, {@code maxQueueSize} is the maximum number of data blocks.
+ *
+ * If specified as an integer followed by "KB", MB", or "GB" (for example,
+ * "100MB"), {@code maxQueueSize} indicates the maximum RAM allocated
+ * to the queue buffer. The default is 500KB (which means a maximum size of
+ * 500KB for the output queue and 1500KB for the wait queue, if any).
+ *
+ * @param maxQueueSize The maximum queue size as a number, or a number
+ * followed by "KB", MB", or "GB".
+ */
+ public void setMaxQueueSize(String maxQueueSize) {
+ setCacheValue("maxQueueSize", maxQueueSize);
+ }
+
+ /**
+ * Sets the type of output processor. Valid values are "tcpout" and
+ * "syslog".
+ *
+ * @param method The output processor type.
+ */
+ public void setMethod(String method) {
+ setCacheValue("method", method);
+ }
+
+ /**
+ * Sets whether to forward cooked data.
+ *
+ * @param sendCookedData {@code true} for Splunk to process events before
+ * sending them, {@code false} to send raw and untouched events.
+ */
+ public void setSendCookedData(boolean sendCookedData) {
+ setCacheValue("sendCookedData", sendCookedData);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public void update(Map 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() {
+ // If not present in the update keys, add required attribute as long
+ // as one pre-existing update pair exists
+ if (toUpdate.size() > 0 && !toUpdate.containsKey("servers")) {
+ setCacheValue("servers", getString("servers"));
+ }
+ super.update();
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/OutputServer.java b/splunk/src/main/java/com/splunk/OutputServer.java
new file mode 100644
index 00000000..cafec3f6
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/OutputServer.java
@@ -0,0 +1,203 @@
+/*
+ * 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;
+
+/**
+ * The {@code OutputServer} class represents an output server, providing access
+ * to data-forwarding configurations.
+ */
+public class OutputServer extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The output server endpoint.
+ */
+ OutputServer(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the DNS name of the destination server for this connection.
+ *
+ * @return The destination host name.
+ */
+ public String getDestHost() {
+ return getString("destHost", null);
+ }
+
+ /**
+ * Returns the IP address of the destination server for this connection.
+ *
+ * @return The IP address of the destination server.
+ */
+ public String getDestIp() {
+ return getString("destIp", null);
+ }
+
+ /**
+ * Return the port on which the destination server is listening.
+ *
+ * @return The destination port.
+ */
+ public int getDestPort() {
+ return getInteger("destPort", 0);
+ }
+
+ /**
+ * Returns the data distribution method used when two or more servers exist
+ * in the same forwarder group. Valid values are: "clone", "balance", and
+ * "autobalance".
+ *
+ * @return The data distribution method.
+ */
+ public String getMethod() {
+ return getString("method");
+ }
+
+ /**
+ * Returns the port on the destination server where data is forwarded.
+ *
+ * @return The source port.
+ */
+ public int getSourcePort() {
+ return getInteger("sourcePort", 0);
+ }
+
+ /**
+ * Returns the server connection status (usually "connect_done",
+ * "connect_fail", or "connect_try").
+ *
+ * @return The connection status.
+ */
+ public String getStatus() {
+ return getString("status", null);
+ }
+
+ /**
+ * Returns client certificate path.
+ *
+ * @return Path of client certificate.
+ */
+ public String getClientCert() {
+ return getString("clientCert", "");
+ }
+
+ /**
+ * Sets the type of data distribution method when two or more servers
+ * exist in the same forwarder group. Valid values are: "clone", "balance",
+ * and "autobalance".
+ *
+ * @param method The data distribution method.
+ */
+ public void setMethod(String method) {
+ setCacheValue("method", method);
+ }
+
+ /**
+ * Sets the alternate name to match in the remote server's SSL certificate.
+ *
+ * @param sslAltNameToCheck The alternate name.
+ */
+ public void setSslAltNameToCheck(String sslAltNameToCheck) {
+ setCacheValue("sslAltNameToCheck", sslAltNameToCheck);
+ }
+
+ /**
+ * Sets the path to the client certificate. If a path is specified, the
+ * connection uses SSL.
+ *
+ * @param sslCertPath The path to the client certificate.
+ */
+ public void setSslCertPath(String sslCertPath) {
+ setCacheValue("sslCertPath", sslCertPath);
+ }
+
+ /**
+ * Sets the SSL cipher in the form:
+ * {@code ALL:!aNULL:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM}
+ *
+ * @param sslCipher The SSL cipher.
+ */
+ public void setSslCipher(String sslCipher) {
+ setCacheValue("sslCipher", sslCipher);
+ }
+
+ /**
+ * Sets the name against which to check the common name of the server's
+ * certificate. If there is no match, you can assume that Splunk is not
+ * authenticated against this server. You must set a value for this
+ * parameter if {@code SslVerifyServerCert} is {@code true}.
+ * @see #setSslVerifyServerCert
+ *
+ * @param sslCommonNameToCheck The SSL common name.
+ */
+ public void setSslCommonNameToCheck(String sslCommonNameToCheck) {
+ setCacheValue("sslCommonNameToCheck", sslCommonNameToCheck);
+ }
+
+ /**
+ * Sets the password associated with the PEM file store.
+ *
+ * @param sslPassword The password.
+ */
+ public void setSslPassword(String sslPassword) {
+ setCacheValue("sslPassword", sslPassword);
+ }
+
+ /**
+ * Sets the path to the root certificate authority file.
+ *
+ * @param sslRootCAPath The path to the root certificate authority file.
+ */
+ public void setSslRootCAPath(String sslRootCAPath) {
+ setCacheValue("sslRootCAPath", sslRootCAPath);
+ }
+
+ /**
+ * Sets whether the server being connected to is authenticated.
+ * Both the common name and the alternate name of the server are checked
+ * for a match.
+ *
+ * @param sslVerifyServerCert {@code true} to determine whether the server
+ * is authenticated, {@code false} if not.
+ */
+ public void setSslVerifyServerCert(boolean sslVerifyServerCert) {
+ setCacheValue("sslVerifyServerCert", sslVerifyServerCert);
+ }
+
+ /**
+ * Sets the client certificate path which is being supported in recent versions.
+ *
+ * @param clientCert The path for client certificate.
+ */
+ public void setClientCert(String clientCert) {
+ setCacheValue("clientCert", clientCert);
+ }
+
+ /**
+ * Returns an object that contains all current connections to the output
+ * server.
+ *
+ * @return The {@code OutputServerAllConnections} object.
+ */
+ public OutputServerAllConnections allConnections() {
+ return new OutputServerAllConnections(
+ service, path + "/allconnections");
+ }
+}
diff --git a/splunk/com/splunk/OutputServerAllConnections.java b/splunk/src/main/java/com/splunk/OutputServerAllConnections.java
similarity index 64%
rename from splunk/com/splunk/OutputServerAllConnections.java
rename to splunk/src/main/java/com/splunk/OutputServerAllConnections.java
index d61806b5..6d1a6aca 100644
--- a/splunk/com/splunk/OutputServerAllConnections.java
+++ b/splunk/src/main/java/com/splunk/OutputServerAllConnections.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,15 @@
package com.splunk;
/**
- * Representation of an output server's connections.
+ * The {@code OutputServerAllConnections} class represents all the connections
+ * of an output server.
*/
public class OutputServerAllConnections extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The output server all-connections endpoint.
*/
OutputServerAllConnections(Service service, String path) {
@@ -32,45 +33,45 @@ public class OutputServerAllConnections extends Entity {
}
/**
- * Returns this connection's destination host name.
+ * Returns the DNS name of the destination server.
*
- * @return This connection's destination host name.
+ * @return The destination host name.
*/
public String getDestHost() {
return getString("destHost");
}
/**
- * Returns this connection's destination host IP address.
+ * Returns the IP address of the destination server for this connection.
*
- * @return This connection's destination host IP address.
+ * @return The IP address of the destination server.
*/
public String getDestIp() {
return getString("destIp");
}
/**
- * Return this connection's destination port.
+ * Return the port on which the destination server is listening.
*
- * @return This connection's destination port.
+ * @return The destination port.
*/
public int getDestPort() {
return getInteger("destPort");
}
/**
- * Returns this connection's source port.
+ * Returns the port on the destination server where data is forwarded.
*
- * @return This connection's source port.
+ * @return The source port.
*/
public int getSourcePort() {
return getInteger("sourcePort");
}
/**
- * Returns this connection's status.
+ * Returns the status of this connection.
*
- * @return This connection's status.
+ * @return The status.
*/
public String getStatus() {
return getString("status");
diff --git a/splunk/src/main/java/com/splunk/OutputSyslog.java b/splunk/src/main/java/com/splunk/OutputSyslog.java
new file mode 100644
index 00000000..81eef76c
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/OutputSyslog.java
@@ -0,0 +1,96 @@
+/*
+ * 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;
+
+/**
+ * The {@code OutputSyslog} class represents a syslog output, providing access
+ * to properties of a forwarding server that provides data in standard syslog
+ * format.
+ */
+public class OutputSyslog extends Entity {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param path The output syslog endpoint.
+ */
+ OutputSyslog(Service service, String path) {
+ super(service, path);
+ }
+
+ /**
+ * Returns the destination {@code host:port} of this server.
+ *
+ * @return The destination {@code host:port}.
+ */
+ public String getServer() {
+ return getString("server");
+ }
+
+ /**
+ * Returns the connection type of this server.
+ *
+ * @return The connection type.
+ */
+ public String getType() {
+ return getString("type");
+ }
+
+ /**
+ * Sets the syslog priority. For more information about the correct values
+ * and format, see
+ * outputs.conf in the Admin Manual.
+ *
+ * @param priority The syslog priority.
+ */
+ public void setPriority(int priority) {
+ setCacheValue("priority", priority);
+ }
+
+ /**
+ * Sets the {@code host:port} where the syslog data is sent.
+ *
+ * @param server The destination {@code host:port}.
+ */
+ public void setServer(String server) {
+ setCacheValue("server", server);
+ }
+
+ /**
+ * Sets the timestamp format that precedes each event that is sent. For more
+ * information about this format, see
+ * outputs.conf in the Admin Manual.
+ *
+ * @param timestampformat The timestamp format.
+ */
+ public void setTimestampFormat(String timestampformat) {
+ setCacheValue("timestampformat", timestampformat);
+ }
+
+ /**
+ * Sets the protocol to use to send syslog data. Valid values are "tcp" and
+ * "udp".
+ *
+ * @param type The protocol type.
+ */
+ public void setType(String type) {
+ setCacheValue("type", type);
+ }
+}
diff --git a/splunk/com/splunk/Password.java b/splunk/src/main/java/com/splunk/Password.java
similarity index 60%
rename from splunk/com/splunk/Password.java
rename to splunk/src/main/java/com/splunk/Password.java
index 19465eb8..66510ede 100644
--- a/splunk/com/splunk/Password.java
+++ b/splunk/src/main/java/com/splunk/Password.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Splunk, Inc.
+ * 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
@@ -17,14 +17,14 @@
package com.splunk;
/**
- * Represenration of saved credential.
+ * The {@code Password} class represents a saved credential.
*/
public class Password extends Entity {
/**
- * Class Constructor.
+ * Class constructor.
*
- * @param service The connected service instance.
+ * @param service The connected {@code Service} instance.
* @param path The password endpoint.
*/
Password(Service service, String path) {
@@ -32,56 +32,66 @@ public class Password extends Entity {
}
/**
- * Returns this credential's clear-text password.
+ * Returns the clear-text password for this credential.
*
- * @return This credential's clear-text password.
+ * @return The clear-text password.
*/
public String getClearPassword() {
return getString("clear_password");
}
/**
- * Returns this credential's encrypted password.
+ * Returns the encrypted password for this credential.
*
- * @return This credential's encrypted password.
+ * @return The encrypted password.
*/
public String getEncryptedPassword() {
return getString("encr_password");
}
/**
- * Returns this credentials username.
+ * Returns the username for this credential.
*
- * @return This credentials username.
+ * @return The username.
*/
@Override public String getName() {
return getUsername();
}
/**
- * Returns this credentials displayable password string.
+ * Returns the displayable password string for this credential.
*
- * @return This credentials displayable password string.
+ * @return The displayable password string, as asterisks.
*/
public String getPassword() {
return getString("password");
}
/**
- * Returns this credentials realm.
+ * Returns the credential realm.
*
- * @return This credentials realm.
+ * @return The realm.
*/
public String getRealm() {
return getString("realm", null);
}
/**
- * Returns this credentials username.
+ * Returns the username for this credential.
*
- * @return This credentials username.
+ * @return The username.
*/
public String getUsername() {
return getString("username");
}
+
+
+ /**
+ * Sets the password for this credential.
+ *
+ * @param password The password.
+ */
+ public void setPassword(String password) {
+ setCacheValue("password", password);
+ }
}
diff --git a/splunk/src/main/java/com/splunk/PasswordCollection.java b/splunk/src/main/java/com/splunk/PasswordCollection.java
new file mode 100644
index 00000000..47a50a22
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/PasswordCollection.java
@@ -0,0 +1,152 @@
+/*
+ * 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;
+
+/**
+ * The {@code PasswordCollection} class represents a collection of credentials.
+ */
+public class PasswordCollection extends EntityCollection {
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ */
+ PasswordCollection(Service service) {
+ super(service, service.passwordEndPoint, Password.class);
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param service The connected {@code Service} instance.
+ * @param args Collection arguments that specify the number of entities to
+ * return and how to sort them. See {@link CollectionArgs}.
+ */
+ PasswordCollection(Service service, Args args) {
+ super(service, service.passwordEndPoint, Password.class, args);
+ }
+
+ /**
+ * Creates a credential with a username and password.
+ *
+ * @param name The username.
+ * @param password The password.
+ *
+ * @return The new credential.
+ */
+ public Password create(String name, String password) {
+ if(checkForWildcards()){
+ throw new IllegalArgumentException("While creating StoragePasswords, namespace cannot have wildcards.");
+ }
+ Args args = new Args("password", password);
+ return create(name, args);
+ }
+
+ /**
+ * Creates a credential with a username, password, and realm.
+ *
+ * @param name The username.
+ * @param password The password.
+ * @param realm The credential realm.
+ * @return The new credential.
+ */
+ public Password create(String name, String password, String realm) {
+ if(checkForWildcards()){
+ throw new IllegalArgumentException("While creating StoragePasswords, namespace cannot have wildcards.");
+ }
+ Args args = new Args();
+ args.put("password", password);
+ args.put("realm", realm);
+ return create(name, args);
+ }
+
+ /**
+ * Get a credential with realm and name.
+ *
+ * @param realm The credential realm.
+ * @param name The username.
+ * @return The credential, or null if not found.
+ */
+ public Password get(String realm, String name) {
+ return super.get(String.format("%s:%s:", realm, name));
+ }
+
+ @Override
+ public Password get(Object key) {
+ // Make it compatible with the old way (low-efficient)
+ if (key instanceof String && !((String) key).contains(":")) {
+ return getByUsername((String) key);
+ }
+ return super.get(key);
+ }
+
+ /**
+ * Remove a credential with realm and name.
+ *
+ * @param realm The credential realm.
+ * @param name The username.
+ * @return The removed credential, or null if not found.
+ */
+ public Password remove(String realm, String name) {
+ if(checkForWildcards()){
+ throw new IllegalArgumentException("app context must be specified when removing a password.");
+ }
+ return super.remove(String.format("%s:%s:", realm, name));
+ }
+
+ @Override
+ public Password remove(String key) {
+ if(checkForWildcards()){
+ throw new IllegalArgumentException("app context must be specified when removing a password.");
+ }
+ // Make it compatible with the old way (low-efficient)
+ if (!key.contains(":")) {
+ Password password = getByUsername((String) key);
+ validate();
+ if (password == null) return null;
+ password.remove();
+ // by invalidating any access to items will get refreshed
+ invalidate();
+ return password;
+ }
+ return super.remove(key);
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ if (key instanceof String && !((String) key).contains(":")) {
+ return getByUsername((String) key) != null;
+ }
+ return super.containsKey(key);
+ }
+
+ private Password getByUsername(String name) {
+ for (Password password : this.values()) {
+ if (password.getUsername().equals(name)) return password;
+ }
+ return null;
+ }
+
+ private boolean checkForWildcards(){
+ boolean isWildCard = false;
+ if(("-").equals(service.getOwner()) || ("-").equals(service.getApp())){
+ isWildCard = true;
+ }
+ return isWildCard;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/Pivot.java b/splunk/src/main/java/com/splunk/Pivot.java
new file mode 100644
index 00000000..d59943a8
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/Pivot.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2014 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.InputStream;
+
+/**
+ * A call of pivot on a PivotSpecification object queries splunkd to get the queries corresponding to that
+ * pivot, which will be returned as an instance of the Pivot class. Pivot is a container for the various
+ * queries for different purposes returned by the server.
+ */
+public class Pivot {
+ private final String openInSearch;
+ private final String drilldownSearch;
+ private final String pivotSearch;
+ private final String tstatsSearch;
+ private final Service service;
+ private final String search;
+
+ private Pivot(Service service, AtomEntry entry) {
+ this.service = service;
+ this.openInSearch = entry.content.getString("open_in_search");
+ this.drilldownSearch = entry.content.getString("drilldown_search");
+ this.pivotSearch = entry.content.getString("pivot_search");
+ this.search = entry.content.getString("search");
+ this.tstatsSearch = entry.content.getString("tstats_search", null);
+ }
+
+ /**
+ * @return a SPL query using the pivot search command to implement this pivot.
+ */
+ public String getPivotQuery() { return this.pivotSearch; }
+
+ /**
+ * @return an SPL query that uses tstats and a tsidx namespace to implement an accelerated
+ * version of this pivot. If there is no acceleration available, it returns null.
+ */
+ public String getAcceleratedQuery() { return this.tstatsSearch; }
+
+ /**
+ * @return an SPL query implementing this pivot that is appropriate for use when implementing
+ * drilldown interfaces.
+ */
+ public String getQueryForDrilldown() { return this.drilldownSearch; }
+
+ /**
+ * @return a readable version of the SPL query implementing this pivot.
+ */
+ public String getPrettyQuery() { return this.openInSearch; }
+
+ /**
+ * @return an SPL query implementing this pivot with no reference to the pivot command.
+ */
+ public String getRawQuery() { return this.search; }
+
+ /**
+ * @return a Job object running this pivot, accelerated if possible.
+ */
+ public Job run() {
+ return run(new JobArgs());
+ }
+
+ /**
+ * @param args options for creating a Job
+ * @return a Job object running this pivot, accelerated if possible.
+ */
+ public Job run(JobArgs args) {
+ if (this.getAcceleratedQuery() == null) {
+ return service.search(this.getPivotQuery(), args);
+ } else {
+ return service.search(this.getAcceleratedQuery(), args);
+ }
+ }
+
+ /**
+ * Parse a pivot from a response from splunkd.
+ *
+ * @param service The HTTP service this pivot operates on.
+ * @param content an InputStream returned by an HTTP response.
+ * @return a Pivot object.
+ */
+ static Pivot parseStream(Service service, InputStream content) {
+ AtomFeed feed = AtomFeed.parseStream(content);
+ if (feed.entries.size() != 1) {
+ throw new IllegalStateException("Expected one Atom entry; found " + feed.entries.size());
+ }
+ AtomEntry entry = feed.entries.get(0);
+ return new Pivot(service, entry);
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/PivotCellValue.java b/splunk/src/main/java/com/splunk/PivotCellValue.java
new file mode 100644
index 00000000..3964c159
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/PivotCellValue.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonObject;
+
+/**
+ * Represents an aggregate value to appear in the cells of a pivot.
+ */
+public class PivotCellValue {
+ private final String fieldName;
+ private final DataModelObject dataModelObject;
+ private final String label;
+ private final StatsFunction statsFunction;
+
+ PivotCellValue(DataModelObject dataModelObject, String fieldName, String label, StatsFunction statsFunction) {
+ this.fieldName = fieldName;
+ this.dataModelObject = dataModelObject;
+ this.label = label;
+ this.statsFunction = statsFunction;
+
+ if (!dataModelObject.containsField(fieldName)) {
+ throw new IllegalArgumentException("No such field named " + fieldName + " on data model object.");
+ }
+
+ FieldType t = dataModelObject.getField(fieldName).getType();
+
+ if ((t == FieldType.STRING || t == FieldType.IPV4) &&
+ statsFunction != StatsFunction.LIST &&
+ statsFunction != StatsFunction.DISTINCT_VALUES &&
+ statsFunction != StatsFunction.FIRST &&
+ statsFunction != StatsFunction.LAST &&
+ statsFunction != StatsFunction.COUNT &&
+ statsFunction != StatsFunction.DISTINCT_COUNT) {
+ throw new IllegalArgumentException("Stats function on string and IPv4 field must be one of " +
+ "list, distinct_values, first, last, count, or distinct_count; found "
+ + statsFunction.toString()
+ );
+ } else if (t == FieldType.NUMBER &&
+ statsFunction != StatsFunction.SUM &&
+ statsFunction != StatsFunction.COUNT &&
+ statsFunction != StatsFunction.AVERAGE &&
+ statsFunction != StatsFunction.MAX &&
+ statsFunction != StatsFunction.MIN &&
+ statsFunction != StatsFunction.STDEV &&
+ statsFunction != StatsFunction.LIST &&
+ statsFunction != StatsFunction.DISTINCT_VALUES) {
+ throw new IllegalArgumentException("Stats function on number field must be one of " +
+ "sum, count, average, max, min, stdev, list, or distinct_values; found "
+ + statsFunction.toString()
+ );
+ } else if (t == FieldType.TIMESTAMP &&
+ statsFunction != StatsFunction.DURATION &&
+ statsFunction != StatsFunction.EARLIEST &&
+ statsFunction != StatsFunction.LATEST &&
+ statsFunction != StatsFunction.LIST &&
+ statsFunction != StatsFunction.DISTINCT_VALUES) {
+ throw new IllegalArgumentException("Stats function on timestamp field must be one of " +
+ "duration, earliest, latest, list, or distinct_values; found "
+ + statsFunction.toString()
+ );
+ } else if ((t == FieldType.CHILDCOUNT || t == FieldType.OBJECTCOUNT) &&
+ statsFunction != StatsFunction.COUNT) {
+ throw new IllegalArgumentException("Stats function on childcount and objectcount fields must be count; " +
+ "; found " + statsFunction.toString()
+ );
+ } else if (t == FieldType.BOOLEAN) {
+ throw new IllegalArgumentException("Cannot use boolean valued fields as cell values.");
+ }
+ }
+
+ /**
+ * @return the name of the field to aggregate on.
+ */
+ public String getFieldName() { return this.fieldName; }
+
+ /**
+ * @return the data model object this pivot is operating on.
+ */
+ public DataModelObject getOwner() { return this.dataModelObject; }
+
+ /**
+ * @return a human readable name for this aggregate.
+ */
+ public String getLabel() { return this.label; }
+
+ /**
+ * @return the function used for aggregation.
+ */
+ public StatsFunction getStatsFunction() { return this.statsFunction; }
+
+ /**
+ * @return a JSON serialization of this object.
+ */
+ JsonObject toJson() {
+ JsonObject root = new JsonObject();
+
+ DataModelField f = this.dataModelObject.getField(fieldName);
+
+ root.addProperty("fieldName", this.fieldName);
+ root.addProperty("owner", Util.join(".", f.getOwnerLineage()));
+ root.addProperty("type", f.getType().toString());
+ root.addProperty("label", this.label);
+ root.addProperty("sparkline", false); // Not properly implemented in core yet.
+ root.addProperty("value", this.statsFunction.toString());
+
+ return root;
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/PivotColumnSplit.java b/splunk/src/main/java/com/splunk/PivotColumnSplit.java
new file mode 100644
index 00000000..838439da
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/PivotColumnSplit.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonObject;
+
+public abstract class PivotColumnSplit {
+ private final String fieldName;
+ private final DataModelObject owner;
+
+ PivotColumnSplit(DataModelObject owner, String fieldName) {
+ this.fieldName = fieldName;
+ this.owner = owner;
+ }
+
+ public String getFieldName() { return this.fieldName; }
+
+ public DataModelObject getOwner() { return this.owner; }
+
+ protected void addCommonFields(JsonObject obj) {
+ DataModelField field = this.owner.getField(this.fieldName);
+
+ obj.addProperty("fieldName", this.fieldName);
+ obj.addProperty("owner", Util.join(".", field.getOwnerLineage()));
+ obj.addProperty("type", field.getType().toString());
+ }
+
+ abstract JsonObject toJson();
+}
diff --git a/splunk/src/main/java/com/splunk/PivotFilter.java b/splunk/src/main/java/com/splunk/PivotFilter.java
new file mode 100644
index 00000000..21645ef3
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/PivotFilter.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+import java.util.ArrayList;
+
+/**
+ * Base class representing filters in pivots.
+ */
+public abstract class PivotFilter {
+ protected final DataModelObject dataModelObject;
+ protected final String fieldName;
+
+ PivotFilter(DataModelObject dataModelObject, String fieldName) {
+ this.dataModelObject = dataModelObject;
+ if (!dataModelObject.containsField(fieldName)) {
+ throw new IllegalArgumentException("No such field " + fieldName + " on specified data model object.");
+ }
+ this.fieldName = fieldName;
+ }
+
+ /**
+ * @return the name of the data model object this filter's field is defined on.
+ */
+ public String getOwnerName() { return this.dataModelObject.getField(this.fieldName).getOwnerName(); }
+
+ /**
+ * @return return the lineage, most remote ancestor first, of the data model object his filter's field is
+ * defined on.
+ */
+ public String[] getOwnerLineage() { return this.dataModelObject.getField(this.fieldName).getOwnerLineage(); }
+
+ /**
+ * @return the name of the field to filter on.
+ */
+ public String getFieldName() {
+ return this.fieldName;
+ }
+
+ /**
+ * @return the type of the field we are filtering on.
+ */
+ public FieldType getType() {
+ return this.dataModelObject.getField(fieldName).getType();
+ }
+
+ /**
+ * @return a JSON serialization of this object.
+ */
+ abstract JsonElement toJson();
+
+ /**
+ * Called by subclasses to add the fields common to all subclasses to JSON serializations.
+ *
+ * @param root a JsonObject instance representing a serialization of this object.
+ */
+ protected void addCommonFields(JsonObject root) {
+ root.addProperty("fieldName", this.fieldName);
+ root.addProperty("owner", Util.join(".", this.dataModelObject.getField(fieldName).getOwnerLineage()));
+ root.addProperty("type", this.getType().toString());
+ }
+}
diff --git a/splunk/src/main/java/com/splunk/PivotRowSplit.java b/splunk/src/main/java/com/splunk/PivotRowSplit.java
new file mode 100644
index 00000000..0fda18b7
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/PivotRowSplit.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2014 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 com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+/**
+ * Base class representing row splits in a pivot.
+ */
+public abstract class PivotRowSplit {
+ private final String fieldName;
+ private final DataModelObject dataModelObject;
+ private final String label;
+
+ PivotRowSplit(DataModelObject dataModelObject, String fieldName, String label) {
+ this.fieldName = fieldName;
+ this.dataModelObject = dataModelObject;
+ this.label = label;
+ }
+
+ /**
+ * @return the name of the field to split on.
+ */
+ public String getFieldName() { return this.fieldName; }
+
+ /**
+ * @return the name of the data model object on which this split's field is defined.
+ */
+ public String getOwnerName() { return this.dataModelObject.getField(fieldName).getOwnerName(); }
+
+ /**
+ * @return the lineage, most remote ancestor first, on which the split's field is defined.
+ */
+ public String[] getOwnerLineage() { return this.dataModelObject.getField(fieldName).getOwnerLineage(); }
+
+ /**
+ * @return a human readable label for this split.
+ */
+ public String getLabel() { return this.label; }
+
+ /**
+ * Add keys common to all row splits to a JSON serialization.
+ *
+ * @param obj JSON serialization to modify.
+ */
+ protected void addCommonFields(JsonObject obj) {
+ DataModelField field = this.dataModelObject.getField(this.fieldName);
+
+ obj.addProperty("fieldName", this.fieldName);
+ obj.addProperty("owner", Util.join(".", field.getOwnerLineage()));
+ obj.addProperty("type", field.getType().toString());
+ obj.addProperty("label", this.label);
+ }
+
+ /**
+ * @return a JSON serialization of this object.
+ */
+ abstract JsonElement toJson();
+}
diff --git a/splunk/src/main/java/com/splunk/PivotSpecification.java b/splunk/src/main/java/com/splunk/PivotSpecification.java
new file mode 100644
index 00000000..1aa154a9
--- /dev/null
+++ b/splunk/src/main/java/com/splunk/PivotSpecification.java
@@ -0,0 +1,491 @@
+/*
+ * Copyright 2014 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 com.google.gson.*;
+
+import java.util.*;
+
+/**
+ * PivotSpecification represents a pivot to be done on a particular data model object. The user creates a
+ * PivotSpecification on some data model object, adds filters, row splits, column splits, and cell values,
+ * then calls the pivot method to query splunkd and get a set of SPL queries corresponding to this specification.
+ */
+public class PivotSpecification {
+ private static GsonBuilder gson = new GsonBuilder();
+
+ private DataModelObject dataModelObject;
+ private String accelerationNamespace = null;
+
+ private List columns = new ArrayList();
+ private List filters = new ArrayList();
+ private List cells = new ArrayList();
+ private List rows = new ArrayList();
+
+ PivotSpecification(DataModelObject dataModelObject) {
+ this.dataModelObject = dataModelObject;
+ if (dataModelObject.getDataModel().isAccelerated()) {
+ this.accelerationNamespace = dataModelObject.getDataModel().getName();
+ } else {
+ this.accelerationNamespace = null;
+ }
+ }
+
+ /**
+ * Set the namespace to use for this acceleration, usually the name of a data model. A value of null will set no
+ * namespace for acceleration.
+ *
+ * @param namespace a string specifying a namespace.
+ * @return PivotSpecification instance
+ */
+ public PivotSpecification setAccelerationNamespace(String namespace) {
+ this.accelerationNamespace = namespace;
+ return this;
+ }
+
+ /**
+ * Set a job with a query ending in tscollect, usually generated by createLocalAccelerationJob on a
+ * DataModelObject instance, as the acceleration cache for this pivot.
+ *
+ * @param sid the SID of a job.
+ * @return PivotSpecification instance
+ */
+ public PivotSpecification setAccelerationJob(String sid) {
+ if (sid == null) {
+ throw new IllegalArgumentException("Sid to use for acceleration must not be null.");
+ } else {
+ this.accelerationNamespace = "sid=" + sid;
+ }
+ return this;
+ }
+
+ /**
+ * Set a job with a query ending in tscollect, usually generated by createLocalAccelerationJob on a
+ * DataModelObject instance, as the acceleration cache for this pivot.
+ *
+ * @param job a Job object.
+ * @return PivotSpecification instance
+ */
+ public PivotSpecification setAccelerationJob(Job job) {
+ setAccelerationJob(job.getSid());
+ return this;
+ }
+
+ /**
+ * @return the acceleration namespace to use in this pivot.
+ */
+ public String getAccelerationNamespace() {
+ return this.accelerationNamespace;
+ }
+
+ private void assertCorrectlyTypedField(String fieldName, FieldType[] acceptableTypes) {
+ DataModelField field = this.dataModelObject.getField(fieldName);
+ if (field == null) {
+ throw new IllegalArgumentException("No such field named " + fieldName);
+ } else if (!Arrays.asList(acceptableTypes).contains(field.getType())) {
+ StringBuilder errorMessage = new StringBuilder();
+ errorMessage.append("Expected a field of one of the following types: ");
+ boolean first = true;
+ for (FieldType t : acceptableTypes) {
+ if (!first) errorMessage.append(", ");
+ errorMessage.append(t.toString());
+ first = false;
+ }
+ errorMessage.append("; found type " + field.getType().toString());
+ throw new IllegalArgumentException(errorMessage.toString());
+ }
+ }
+
+ private void assertCorrectlyTypedField(String field, FieldType acceptableType) {
+ assertCorrectlyTypedField(field, new FieldType[] { acceptableType });
+ }
+
+ /**
+ * Add a filter on a boolean valued field. The filter will be a constraint of the form
+ *
+ * field `comparison` compareTo
+ *
+ * for example
+ *
+ * is_remote = false
+ *
+ * @param field the name of the field
+ * @param comparison a comparison operator for the filter
+ * @param compareTo the value to compare the field to
+ * @return the PivotSpecification you are operating on.
+ */
+ public PivotSpecification addFilter(String field, BooleanComparison comparison, boolean compareTo) {
+ assertCorrectlyTypedField(field, FieldType.BOOLEAN);
+
+ BooleanPivotFilter filter = new BooleanPivotFilter(this.dataModelObject, field, comparison, compareTo);
+ filters.add(filter);
+
+ return this;
+ }
+
+ /**
+ * Add a filter on a string valued field. The filter will be a constraint of the form
+ *
+ * field `comparison` compareTo
+ *
+ * for example
+ *
+ * host startswith 'boris'
+ *
+ * @param field the name of the field
+ * @param comparison a comparison operator for the filter
+ * @param comparisonValue the value to compare the field to
+ * @return the PivotSpecification you are operating on.
+ */
+ public PivotSpecification addFilter(String field, StringComparison comparison, String comparisonValue) {
+ assertCorrectlyTypedField(field, FieldType.STRING);
+
+ StringPivotFilter filter = new StringPivotFilter(this.dataModelObject, field, comparison, comparisonValue);
+ filters.add(filter);
+
+ return this;
+ }
+
+ /**
+ * Add a filter on an IPv4 valued field. The filter will be a constraint of the form
+ *
+ * field `comparison` compareTo
+ *
+ * for example
+ *
+ * hostip = 192.168.100.12
+ *
+ * @param field the name of the field
+ * @param comparison a comparison operator for the filter
+ * @param comparisonValue the value to compare the field to
+ * @return the PivotSpecification you are operating on.
+ */
+ public PivotSpecification addFilter(String field, IPv4Comparison comparison, String comparisonValue) {
+ assertCorrectlyTypedField(field, FieldType.IPV4);
+
+ IPv4PivotFilter filter = new IPv4PivotFilter(this.dataModelObject, field, comparison, comparisonValue);
+ filters.add(filter);
+
+ return this;
+ }
+
+ /**
+ * Add a filter on a numeric field. The filter will be a constraint of the form
+ *
+ * field `comparison` compareTo
+ *
+ * for example
+ *
+ * {@code height > 6}
+ *
+ * @param field the name of the field
+ * @param comparison a comparison operator for the filter
+ * @param comparisonValue the value to compare the field to
+ * @return the PivotSpecification you are operating on.
+ */
+ public PivotSpecification addFilter(String field, NumberComparison comparison, double comparisonValue) {
+ assertCorrectlyTypedField(field, FieldType.NUMBER);
+
+ NumberPivotFilter filter = new NumberPivotFilter(this.dataModelObject, field, comparison, comparisonValue);
+ filters.add(filter);
+
+ return this;
+ }
+
+ /**
+ * Add a filter that limits the number of values of an aggregated field that will be allowed
+ * into the pivot.
+ *
+ * @param field the name of a field
+ * @param sortAttribute field to aggregate for limiting
+ * @param sortDirection whether to take the lowest or highest values of the aggregated field
+ * @param limit how many values of the aggregated field to take
+ * @param statsFunction the function to use for aggregation
+ * @return The PivotSpecification you are modifying.
+ */
+ public PivotSpecification addFilter(String field, String sortAttribute,
+ SortDirection sortDirection, int limit, StatsFunction statsFunction) {
+ if (!dataModelObject.containsField(field)) {
+ throw new IllegalArgumentException("No such field " + sortAttribute);
+ }
+ assertCorrectlyTypedField(
+ sortAttribute,
+ new FieldType[] { FieldType.STRING, FieldType.NUMBER, FieldType.OBJECTCOUNT }
+ );
+
+ LimitPivotFilter filter = new LimitPivotFilter(this.dataModelObject, field, sortAttribute,
+ sortDirection, limit, statsFunction);
+ filters.add(filter);
+
+ return this;
+ }
+
+ /**
+ * Add a row split on a numeric or string valued field, splitting on each distinct value of the field.
+ *
+ * @param field name of the field to split on
+ * @param label a human readable name for this set of rows
+ * @return The PivotSpecification you are modifying.
+ */
+ public PivotSpecification addRowSplit(String field, String label) {
+ assertCorrectlyTypedField(field, new FieldType[] { FieldType.NUMBER, FieldType.STRING });
+
+ FieldType t = this.dataModelObject.getField(field).getType();
+ if (t == FieldType.NUMBER) {
+ rows.add(new NumberPivotRowSplit(this.dataModelObject, field, label));
+ } else if (t == FieldType.STRING) {
+ rows.add(new StringPivotRowSplit(this.dataModelObject, field, label));
+ } else {
+ throw new IllegalArgumentException("Field not of type number or string despite precondition asserting so.");
+ }
+
+ return this;
+ }
+
+ /**
+ * Add a row split on a numeric field, splitting into numeric ranges.
+ *
+ * This split generates bins with edges equivalent to the
+ * classic loop {@code 'for i in to by