mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
**Problem:** For historical reasons, source files for the Elasticsearch Guide's security, watcher, and Logstash API docs are housed in the `x-pack/docs` directory. This can confuse new contributors who expect Elasticsearch Guide docs to be located in `docs/reference`. **Solution:** - Move the security, watcher, and Logstash API doc source files to the `docs/reference` directory - Update doc snippet tests to use security Rel: https://github.com/elastic/platform-docs-team/issues/208
33 lines
No EOL
1 KiB
Text
33 lines
No EOL
1 KiB
Text
[discrete]
|
|
[[api-java-get-watch]]
|
|
=== Get watch API
|
|
|
|
This API retrieves a watch by its id.
|
|
|
|
The following example gets a watch with `my-watch` id:
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
GetWatchResponse getWatchResponse = watcherClient.prepareGetWatch("my-watch").get();
|
|
--------------------------------------------------
|
|
|
|
You can access the watch definition by accessing the source of the response:
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
XContentSource source = getWatchResponse.getSource();
|
|
--------------------------------------------------
|
|
|
|
The `XContentSource` provides you methods to explore the source:
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
Map<String, Object> map = source.getAsMap();
|
|
--------------------------------------------------
|
|
|
|
Or get a specific value associated with a known key:
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
String host = source.getValue("input.http.request.host");
|
|
-------------------------------------------------- |