Module: Elasticsearch::XPack::API::Watcher::Actions

Included in:
WatcherClient
Defined in:
lib/elasticsearch/xpack/api/namespace/watcher.rb,
lib/elasticsearch/xpack/api/actions/watcher/stop.rb,
lib/elasticsearch/xpack/api/actions/watcher/start.rb,
lib/elasticsearch/xpack/api/actions/watcher/stats.rb,
lib/elasticsearch/xpack/api/actions/watcher/ack_watch.rb,
lib/elasticsearch/xpack/api/actions/watcher/get_watch.rb,
lib/elasticsearch/xpack/api/actions/watcher/put_watch.rb,
lib/elasticsearch/xpack/api/actions/watcher/delete_watch.rb,
lib/elasticsearch/xpack/api/actions/watcher/execute_watch.rb,
lib/elasticsearch/xpack/api/actions/watcher/query_watches.rb,
lib/elasticsearch/xpack/api/actions/watcher/activate_watch.rb,
lib/elasticsearch/xpack/api/actions/watcher/params_registry.rb,
lib/elasticsearch/xpack/api/actions/watcher/deactivate_watch.rb

Defined Under Namespace

Modules: ParamsRegistry

Instance Method Summary collapse

Instance Method Details

#ack_watch(arguments = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :watch_id (String)

    Watch ID

  • :action_id (List)

    A comma-separated list of the action ids to be acked

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/elasticsearch/xpack/api/actions/watcher/ack_watch.rb', line 31

def ack_watch(arguments = {})
  raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _watch_id = arguments.delete(:watch_id)

  _action_id = arguments.delete(:action_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _watch_id && _action_id
             "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_watch_id)}/_ack/#{Elasticsearch::API::Utils.__listify(_action_id)}"
           else
             "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_watch_id)}/_ack"
           end
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end

#activate_watch(arguments = {}) ⇒ Object

Activates a currently inactive watch.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :watch_id (String)

    Watch ID

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/elasticsearch/xpack/api/actions/watcher/activate_watch.rb', line 30

def activate_watch(arguments = {})
  raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _watch_id = arguments.delete(:watch_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_watch_id)}/_activate"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end

#deactivate_watch(arguments = {}) ⇒ Object

Deactivates a currently active watch.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :watch_id (String)

    Watch ID

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/elasticsearch/xpack/api/actions/watcher/deactivate_watch.rb', line 30

def deactivate_watch(arguments = {})
  raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _watch_id = arguments.delete(:watch_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_watch_id)}/_deactivate"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end

#delete_watch(arguments = {}) ⇒ Object

Removes a watch from Watcher.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Watch ID

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elasticsearch/xpack/api/actions/watcher/delete_watch.rb', line 30

def delete_watch(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_id)}"
  params = {}

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Elasticsearch::API::Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
  else
    perform_request(method, path, params, body, headers).body
  end
end

#execute_watch(arguments = {}) ⇒ Object

Forces the execution of a stored watch.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Watch ID

  • :debug (Boolean)

    indicates whether the watch should execute in debug mode

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    Execution control

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elasticsearch/xpack/api/actions/watcher/execute_watch.rb', line 32

def execute_watch(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _id
             "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_id)}/_execute"
           else
             "_watcher/watch/_execute"
           end
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end

#get_watch(arguments = {}) ⇒ Object

Retrieves a watch by its ID.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Watch ID

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/elasticsearch/xpack/api/actions/watcher/get_watch.rb', line 30

def get_watch(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_id)}"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end

#put_watch(arguments = {}) ⇒ Object

Creates a new watch, or updates an existing one.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Watch ID

  • :active (Boolean)

    Specify whether the watch is in/active by default

  • :version (Number)

    Explicit version number for concurrency control

  • :if_seq_no (Number)

    only update the watch if the last operation that has changed the watch has the specified sequence number

  • :if_primary_term (Number)

    only update the watch if the last operation that has changed the watch has the specified primary term

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The watch

Raises:

  • (ArgumentError)

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/elasticsearch/xpack/api/actions/watcher/put_watch.rb', line 35

def put_watch(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_watcher/watch/#{Elasticsearch::API::Utils.__listify(_id)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end

#query_watches(arguments = {}) ⇒ Object

Retrieves stored watches.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    From, size, query, sort and search_after

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/elasticsearch/xpack/api/actions/watcher/query_watches.rb', line 30

def query_watches(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = "_watcher/_query/watches"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end

#start(arguments = {}) ⇒ Object

Starts Watcher if it is not already running.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/elasticsearch/xpack/api/actions/watcher/start.rb', line 29

def start(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_watcher/_start"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end

#stats(arguments = {}) ⇒ Object

Retrieves the current Watcher metrics.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :metric (List)

    Controls what additional stat metrics should be include in the response (options: _all, queued_watches, current_watches, pending_watches)

  • :emit_stacktraces (Boolean)

    Emits stack traces of currently running watches

  • :headers (Hash)

    Custom HTTP headers

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/elasticsearch/xpack/api/actions/watcher/stats.rb', line 31

def stats(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _metric = arguments.delete(:metric)

  method = Elasticsearch::API::HTTP_GET
  path   = if _metric
             "_watcher/stats/#{Elasticsearch::API::Utils.__listify(_metric)}"
           else
             "_watcher/stats"
           end
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end

#stop(arguments = {}) ⇒ Object

Stops Watcher if it is running.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/elasticsearch/xpack/api/actions/watcher/stop.rb', line 29

def stop(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_watcher/_stop"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end