Method: Elasticsearch::API::MachineLearning::Actions#put_trained_model

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

#put_trained_model(arguments = {}) ⇒ Object

Creates an inference trained model.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :model_id (String)

    The ID of the trained models to store

  • :defer_definition_decompression (Boolean)

    If set to ‘true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations.

  • :wait_for_completion (Boolean)

    Whether to wait for all child operations(e.g. model download) to complete, before returning or not. Default to false

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The trained model configuration (Required)

Raises:

  • (ArgumentError)

See Also:


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/machine_learning/put_trained_model.rb', line 35

def put_trained_model(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'ml.put_trained_model' }

  defined_params = [:model_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 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id]

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

  body = arguments.delete(:body)

  _model_id = arguments.delete(:model_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_ml/trained_models/#{Utils.__listify(_model_id)}"
  params = Utils.process_params(arguments)

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