112 lines
2.8 KiB
Plaintext
112 lines
2.8 KiB
Plaintext
|
[[api-java]]
|
||
|
=== Java API
|
||
|
Watcher provides a Java client called WatcherClient that adds support for the Watcher APIs to the standard Java clients
|
||
|
that ship with Elasticsearch ({java-client-ref}/transport-client.html[Transport Client] or
|
||
|
the {java-client-ref}/node-client.html[Node Client]).
|
||
|
|
||
|
==== Installing WatcherClient
|
||
|
|
||
|
To use the `WatcherClient` you will need to make sure the `elasticsearch-watcher` JAR file is in the classpath. You can
|
||
|
extract the jar from the downloaded watcher plugin itself.
|
||
|
|
||
|
If you use Maven to manage dependencies, add the following to the `pom.xml`:
|
||
|
|
||
|
[source,xml]
|
||
|
--------------------------------------------------
|
||
|
<project ...>
|
||
|
|
||
|
<repositories>
|
||
|
<!-- add the elasticsearch repo -->
|
||
|
<repository>
|
||
|
<id>elasticsearch-releases</id>
|
||
|
<url>http://maven.elasticsearch.org/releases</url>
|
||
|
<releases>
|
||
|
<enabled>true</enabled>
|
||
|
</releases>
|
||
|
<snapshots>
|
||
|
<enabled>false</enabled>
|
||
|
</snapshots>
|
||
|
</repository>
|
||
|
...
|
||
|
</repositories>
|
||
|
...
|
||
|
|
||
|
<dependencies>
|
||
|
<!-- add the Watcher jar as a dependency -->
|
||
|
<dependency>
|
||
|
<groupId>org.elasticsearch</groupId>
|
||
|
<artifactId>elasticsearch-watcher</artifactId>
|
||
|
<version>1.0.0-Beta1</version>
|
||
|
</dependency>
|
||
|
...
|
||
|
</dependencies>
|
||
|
...
|
||
|
|
||
|
</project>
|
||
|
--------------------------------------------------
|
||
|
|
||
|
If you use Gradle, add the dependencies to `build.gradle`:
|
||
|
|
||
|
[source,groovy]
|
||
|
--------------------------------------------------------------
|
||
|
repositories {
|
||
|
/* ... Any other repositories ... */
|
||
|
|
||
|
// Add the Elasticsearch Maven Repository
|
||
|
maven {
|
||
|
url "http://maven.elasticsearch.org/releases"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
dependencies {
|
||
|
// Provide the Watcher jar on the classpath for compilation and at runtime
|
||
|
compile "org.elasticsearch:elasticsearch-watcher:1.0.0-Beta1"
|
||
|
|
||
|
/* ... */
|
||
|
}
|
||
|
--------------------------------------------------------------
|
||
|
|
||
|
You can manually download the http://maven.elasticsearch.org/releases/org/elasticsearch/elasticsearch-watcher/1.0.0-Beta1/elasticsearch-watcher-1.0.0-Beta1.jar[Watcher JAR]
|
||
|
directly from our Maven repository.
|
||
|
|
||
|
==== Creating the WatcherClient
|
||
|
|
||
|
Creating the `WatcherClient` can simply be done as the following snippet shows:
|
||
|
|
||
|
[source,java]
|
||
|
--------------------------------------------------
|
||
|
import org.elasticsearch.watcher.client.WatcherClient;
|
||
|
...
|
||
|
|
||
|
Client client = ... // create and initialize either the transport or the node client
|
||
|
|
||
|
WatcherClient watcherClient = new WatcherClient(client);
|
||
|
--------------------------------------------------
|
||
|
|
||
|
include::java/put-watch.asciidoc[]
|
||
|
|
||
|
include::java/get-watch.asciidoc[]
|
||
|
|
||
|
include::java/delete-watch.asciidoc[]
|
||
|
|
||
|
include::java/execute-watch.asciidoc[]
|
||
|
|
||
|
include::java/ack-watch.asciidoc[]
|
||
|
|
||
|
include::java/stats.asciidoc[]
|
||
|
|
||
|
include::java/service.asciidoc[]
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|