Module: ElasticsearchServerless::API::Tasks::Actions

Defined in:
lib/elasticsearch-serverless/api/tasks/get.rb

Instance Method Summary collapse

Instance Method Details

#get(arguments = {}) ⇒ Object

Get task information. Returns information about the tasks currently executing in the cluster. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :task_id (String)

    ID of the task. (Required)

  • :timeout (Time)

    Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s.

  • :wait_for_completion (Boolean)

    If true, the request blocks until the task has completed.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
65
# File 'lib/elasticsearch-serverless/api/tasks/get.rb', line 40

def get(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || "tasks.get" }

  defined_params = [:task_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 'task_id' missing" unless arguments[:task_id]

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

  body = nil

  _task_id = arguments.delete(:task_id)

  method = ElasticsearchServerless::API::HTTP_GET
  path   = "_tasks/#{Utils.listify(_task_id)}"
  params = Utils.process_params(arguments)

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