Module: Elasticsearch::XPack::API::Fleet::Actions

Included in:
FleetClient
Defined in:
lib/elasticsearch/xpack/api/namespace/fleet.rb,
lib/elasticsearch/xpack/api/actions/fleet/search.rb,
lib/elasticsearch/xpack/api/actions/fleet/msearch.rb,
lib/elasticsearch/xpack/api/actions/fleet/params_registry.rb,
lib/elasticsearch/xpack/api/actions/fleet/global_checkpoints.rb

Defined Under Namespace

Modules: ParamsRegistry

Instance Method Summary collapse

Instance Method Details

#global_checkpoints(arguments = {}) ⇒ Object

Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The name of the index.

  • :wait_for_advance (Boolean)

    Whether to wait for the global checkpoint to advance past the specified current checkpoints

  • :wait_for_index (Boolean)

    Whether to wait for the target index to exist and all primary shards be active

  • :checkpoints (List)

    Comma separated list of checkpoints

  • :timeout (Time)

    Timeout to wait for global checkpoint to advance

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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

def global_checkpoints(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_GET
  path   = "#{Elasticsearch::API::Utils.__listify(_index)}/_fleet/global_checkpoints"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end

#msearch(arguments = {}) ⇒ Object

Multi Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project. 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):

  • :index (String)

    The index name to use as the default

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The request definitions (metadata-fleet search request definition pairs), separated by newlines (Required)

Raises:

  • (ArgumentError)

See Also:

  • [TODO]


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
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/elasticsearch/xpack/api/actions/fleet/msearch.rb', line 35

def msearch(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index
             "#{Elasticsearch::API::Utils.__listify(_index)}/_fleet/_fleet_msearch"
           else
             "_fleet/_fleet_msearch"
           end
  params = {}

  body = arguments[:body]
  case
  when body.is_a?(Array) && body.any? { |d| d.has_key? :search }
    payload = body
              .inject([]) do |sum, item|
                meta = item
                data = meta.delete(:search)

                sum << meta
                sum << data
                sum
              end
              .map { |item| Elasticsearch::API.serializer.dump(item) }
    payload << "" unless payload.empty?
    payload = payload.join("\n")
  when body.is_a?(Array)
    payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
    payload << "" unless payload.empty?
    payload = payload.join("\n")
  else
    payload = body
  end

  headers = Elasticsearch::API::Utils.ndjson_headers(headers)
  perform_request(method, path, params, payload, headers).body
end

#search(arguments = {}) ⇒ Object

Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project. 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):

  • :index (String)

    The index name to search.

  • :wait_for_checkpoints (List)

    Comma separated list of checkpoints, one per shard

  • :wait_for_checkpoints_timeout (Time)

    Explicit wait_for_checkpoints timeout

  • :allow_partial_search_results (Boolean)

    Indicate if an error should be returned if there is a partial search failure or timeout

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition using the Query DSL

Raises:

  • (ArgumentError)

See Also:

  • [TODO]


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/xpack/api/actions/fleet/search.rb', line 38

def search(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

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

  arguments = arguments.clone
  arguments[:index] = UNDERSCORE_ALL if !arguments[:index] && arguments[:type]

  _index = arguments.delete(:index)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = "#{Elasticsearch::API::Utils.__listify(_index)}/_fleet/_fleet_search"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end