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. Get information about a task currently running in the cluster. WARNING: The task management API is new and should still be considered a beta feature. The API may change in ways that are not backwards compatible. If the task identifier is not found, a 404 response code indicates that there are no resources that match the request. 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)

    The task identifier. (Required)

  • :timeout (Time)

    The 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:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/elasticsearch-serverless/api/tasks/get.rb', line 43

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

  defined_params = [:task_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 '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