Method: Elasticsearch::API::MachineLearning::Actions#start_datafeed

Defined in:
lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb

#start_datafeed(arguments = {}) ⇒ Object

Starts one or more datafeeds.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :datafeed_id (String)

    The ID of the datafeed to start

  • :start (String)

    The start time from where the datafeed should begin

  • :end (String)

    The end time when the datafeed should stop. When not set, the datafeed continues in real time

  • :timeout (Time)

    Controls the time to wait until a datafeed has started. Default to 20 seconds

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The start datafeed parameters

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb', line 36

def start_datafeed(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || "ml.start_datafeed" }

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

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

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

  body = arguments.delete(:body)

  _datafeed_id = arguments.delete(:datafeed_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}/_start"
  params = Utils.process_params(arguments)

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