Watcher

class elasticsearch.client.WatcherClient(client)
Parameters:

client (BaseClient)

ack_watch(*, watch_id, action_id=None, error_trace=None, filter_path=None, human=None, pretty=None)

Acknowledges a watch, manually throttling the execution of the watch’s actions.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-ack-watch.html

Parameters:
  • watch_id (str) – Watch ID

  • action_id (str | Sequence[str] | None) – A comma-separated list of the action ids to be acked

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

activate_watch(*, watch_id, error_trace=None, filter_path=None, human=None, pretty=None)

Activates a currently inactive watch.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-activate-watch.html

Parameters:
Return type:

ObjectApiResponse[Any]

deactivate_watch(*, watch_id, error_trace=None, filter_path=None, human=None, pretty=None)

Deactivates a currently active watch.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-deactivate-watch.html

Parameters:
Return type:

ObjectApiResponse[Any]

delete_watch(*, id, error_trace=None, filter_path=None, human=None, pretty=None)

Removes a watch from Watcher.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-delete-watch.html

Parameters:
Return type:

ObjectApiResponse[Any]

execute_watch(*, id=None, action_modes=None, alternative_input=None, debug=None, error_trace=None, filter_path=None, human=None, ignore_condition=None, pretty=None, record_execution=None, simulated_actions=None, trigger_data=None, watch=None, body=None)

This API can be used to force execution of the watch outside of its triggering logic or to simulate the watch execution for debugging purposes. For testing and debugging purposes, you also have fine-grained control on how the watch runs. You can execute the watch without executing all of its actions or alternatively by simulating them. You can also force execution by ignoring the watch condition and control whether a watch record would be written to the watch history after execution.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-execute-watch.html

Parameters:
  • id (str | None) – Identifier for the watch.

  • action_modes (Mapping[str, str | Literal['execute', 'force_execute', 'force_simulate', 'simulate', 'skip']] | None) – Determines how to handle the watch actions as part of the watch execution.

  • alternative_input (Mapping[str, Any] | None) – When present, the watch uses this object as a payload instead of executing its own input.

  • debug (bool | None) – Defines whether the watch runs in debug mode.

  • ignore_condition (bool | None) – When set to true, the watch execution uses the always condition. This can also be specified as an HTTP parameter.

  • record_execution (bool | None) – When set to true, the watch record representing the watch execution result is persisted to the .watcher-history index for the current time. In addition, the status of the watch is updated, possibly throttling subsequent executions. This can also be specified as an HTTP parameter.

  • simulated_actions (Mapping[str, Any] | None)

  • trigger_data (Mapping[str, Any] | None) – This structure is parsed as the data of the trigger event that will be used during the watch execution

  • watch (Mapping[str, Any] | None) – When present, this watch is used instead of the one specified in the request. This watch is not persisted to the index and record_execution cannot be set.

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]

get_watch(*, id, error_trace=None, filter_path=None, human=None, pretty=None)

Retrieves a watch by its ID.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-get-watch.html

Parameters:
Return type:

ObjectApiResponse[Any]

put_watch(*, id, actions=None, active=None, condition=None, error_trace=None, filter_path=None, human=None, if_primary_term=None, if_seq_no=None, input=None, metadata=None, pretty=None, throttle_period=None, transform=None, trigger=None, version=None, body=None)

Creates a new watch, or updates an existing one.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-put-watch.html

Parameters:
  • id (str) – Watch ID

  • actions (Mapping[str, Mapping[str, Any]] | None)

  • active (bool | None) – Specify whether the watch is in/active by default

  • condition (Mapping[str, Any] | None)

  • if_primary_term (int | None) – only update the watch if the last operation that has changed the watch has the specified primary term

  • if_seq_no (int | None) – only update the watch if the last operation that has changed the watch has the specified sequence number

  • input (Mapping[str, Any] | None)

  • metadata (Mapping[str, Any] | None)

  • throttle_period (str | None)

  • transform (Mapping[str, Any] | None)

  • trigger (Mapping[str, Any] | None)

  • version (int | None) – Explicit version number for concurrency control

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]

query_watches(*, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, query=None, search_after=None, size=None, sort=None, body=None)

Retrieves stored watches.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-query-watches.html

Parameters:
  • from – The offset from the first result to fetch. Needs to be non-negative.

  • query (Mapping[str, Any] | None) – Optional, query filter watches to be returned.

  • search_after (Sequence[None | bool | float | int | str | Any] | None) – Optional search After to do pagination using last hit’s sort values.

  • size (int | None) – The number of hits to return. Needs to be non-negative.

  • sort (Sequence[str | Mapping[str, Any]] | str | Mapping[str, Any] | None) – Optional sort definition.

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • from_ (int | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]

start(*, error_trace=None, filter_path=None, human=None, pretty=None)

Starts Watcher if it is not already running.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-start.html

Parameters:
Return type:

ObjectApiResponse[Any]

stats(*, metric=None, emit_stacktraces=None, error_trace=None, filter_path=None, human=None, pretty=None)

Retrieves the current Watcher metrics.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-stats.html

Parameters:
  • metric (Sequence[str | Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']] | str | ~typing.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches'] | None) – Defines which additional metrics are included in the response.

  • emit_stacktraces (bool | None) – Defines whether stack traces are generated for each watch that is running.

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

stop(*, error_trace=None, filter_path=None, human=None, pretty=None)

Stops Watcher if it is running.

https://www.elastic.co/guide/en/elasticsearch/reference/8.16/watcher-api-stop.html

Parameters:
Return type:

ObjectApiResponse[Any]