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

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

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:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/elasticsearch/api/actions/watcher/ack_watch.rb', line 33

def ack_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.ack_watch' }

  defined_params = %i[watch_id action_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id]

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

  body = nil

  _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/#{Utils.__listify(_watch_id)}/_ack/#{Utils.__listify(_action_id)}"
           else
             "_watcher/watch/#{Utils.__listify(_watch_id)}/_ack"
           end
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



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

def activate_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.activate_watch' }

  defined_params = [:watch_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id]

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

  body = nil

  _watch_id = arguments.delete(:watch_id)

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



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

def deactivate_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.deactivate_watch' }

  defined_params = [:watch_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id]

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

  body = nil

  _watch_id = arguments.delete(:watch_id)

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/elasticsearch/api/actions/watcher/delete_watch.rb', line 32

def delete_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.delete_watch' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

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

  body = nil

  _id = arguments.delete(:id)

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

  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  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:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/elasticsearch/api/actions/watcher/execute_watch.rb', line 34

def execute_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.execute_watch' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

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

  body = arguments.delete(:body)

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _id
             "_watcher/watch/#{Utils.__listify(_id)}/_execute"
           else
             '_watcher/watch/_execute'
           end
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#get_settings(arguments = {}) ⇒ Object

Retrieve settings for the watcher system index

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers

See Also:



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

def get_settings(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.get_settings' }

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

  body   = nil

  method = Elasticsearch::API::HTTP_GET
  path   = '_watcher/settings'
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



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

def get_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.get_watch' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

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

  body = nil

  _id = arguments.delete(:id)

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/elasticsearch/api/actions/watcher/put_watch.rb', line 37

def put_watch(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.put_watch' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

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

  body = arguments.delete(:body)

  _id = arguments.delete(:id)

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



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

def query_watches(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.query_watches' }

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

  body   = arguments.delete(:body)

  method = if body
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



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

def start(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.start' }

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

  body   = nil

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/watcher/stats.rb', line 33

def stats(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.stats' }

  defined_params = [:metric].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

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

  body = nil

  _metric = arguments.delete(:metric)

  method = Elasticsearch::API::HTTP_GET
  path   = if _metric
             "_watcher/stats/#{Utils.__listify(_metric)}"
           else
             '_watcher/stats'
           end
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
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:



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

def stop(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.stop' }

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

  body   = nil

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

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#update_settings(arguments = {}) ⇒ Object

Update settings for the watcher system index

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    An object with the new index settings (Required)

Raises:

  • (ArgumentError)

See Also:



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

def update_settings(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'watcher.update_settings' }

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  body   = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_PUT
  path   = '_watcher/settings'
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end