Module: OpenSearch::API::Cluster::Actions

Included in:
ClusterClient
Defined in:
lib/opensearch/api/namespace/cluster.rb,
lib/opensearch/api/actions/cluster/state.rb,
lib/opensearch/api/actions/cluster/stats.rb,
lib/opensearch/api/actions/cluster/health.rb,
lib/opensearch/api/actions/cluster/reroute.rb,
lib/opensearch/api/actions/cluster/remote_info.rb,
lib/opensearch/api/actions/cluster/get_settings.rb,
lib/opensearch/api/actions/cluster/put_settings.rb,
lib/opensearch/api/actions/cluster/pending_tasks.rb,
lib/opensearch/api/actions/cluster/params_registry.rb,
lib/opensearch/api/actions/cluster/allocation_explain.rb,
lib/opensearch/api/actions/cluster/get_component_template.rb,
lib/opensearch/api/actions/cluster/put_component_template.rb,
lib/opensearch/api/actions/cluster/delete_component_template.rb,
lib/opensearch/api/actions/cluster/exists_component_template.rb,
lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb,
lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb

Defined Under Namespace

Modules: ParamsRegistry

Instance Method Summary collapse

Instance Method Details

#allocation_explain(arguments = {}) ⇒ Object

Provides explanations for shard allocations in the cluster.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :include_yes_decisions (Boolean)

    Return ‘YES’ decisions in explanation (default: false)

  • :include_disk_info (Boolean)

    Return information about disk usage and shard sizes (default: false)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The index, shard, and primary flag to explain. Empty means ‘explain the first unassigned shard’



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/opensearch/api/actions/cluster/allocation_explain.rb', line 39

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

  arguments = arguments.clone

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

  path = "_cluster/allocation/explain"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#delete_component_template(arguments = {}) ⇒ Object

Deletes a component template

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :name (String)

    The name of the template

  • :timeout (Time)

    Explicit operation timeout

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Specify timeout for connection to master

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/opensearch/api/actions/cluster/delete_component_template.rb', line 40

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

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

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = OpenSearch::API::HTTP_DELETE
  path   = "_component_template/#{Utils.__listify(_name)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#delete_voting_config_exclusions(arguments = {}) ⇒ Object

Clears cluster voting config exclusions.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :wait_for_removal (Boolean)

    Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list.

  • :headers (Hash)

    Custom HTTP headers



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb', line 37

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_DELETE
  path   = "_cluster/voting_config_exclusions"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#exists_component_template(arguments = {}) ⇒ Object Also known as: exists_component_template?

Returns information about whether a particular component template exist

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :name (String)

    The name of the template

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Explicit operation timeout for connection to master node

  • :cluster_manager_timeout (Time)

    Explicit operation timeout for connection to cluster_manager node

  • :local (Boolean)

    Return local information, do not retrieve the state from cluster_manager node (default: false)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/opensearch/api/actions/cluster/exists_component_template.rb', line 40

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

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

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = OpenSearch::API::HTTP_HEAD
  path   = "_component_template/#{Utils.__listify(_name)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#get_component_template(arguments = {}) ⇒ Object

Returns one or more component templates

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :name (List)

    The comma separated names of the component templates

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Explicit operation timeout for connection to master node

  • :cluster_manager_timeout (Time)

    Explicit operation timeout for connection to cluster_manager node

  • :local (Boolean)

    Return local information, do not retrieve the state from cluster_manager node (default: false)

  • :headers (Hash)

    Custom HTTP headers



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/opensearch/api/actions/cluster/get_component_template.rb', line 40

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

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = OpenSearch::API::HTTP_GET
  path   = if _name
             "_component_template/#{Utils.__listify(_name)}"
           else
             "_component_template"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#get_settings(arguments = {}) ⇒ Object

Returns cluster settings.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :flat_settings (Boolean)

    Return settings in flat format (default: false)

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Explicit operation timeout for connection to master node

  • :cluster_manager_timeout (Time)

    Explicit operation timeout for connection to cluster_manager node

  • :timeout (Time)

    Explicit operation timeout

  • :include_defaults (Boolean)

    Whether to return all default clusters setting.

  • :headers (Hash)

    Custom HTTP headers



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/opensearch/api/actions/cluster/get_settings.rb', line 41

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_GET
  path   = "_cluster/settings"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#health(arguments = {}) ⇒ Object

Returns basic information about the health of the cluster.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    Limit the information returned to a specific index

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :level (String)

    Specify the level of detail for returned information (options: cluster, indices, shards)

  • :local (Boolean)

    Return local information, do not retrieve the state from cluster_manager node (default: false)

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Explicit operation timeout for connection to master node

  • :cluster_manager_timeout (Time)

    Explicit operation timeout for connection to cluster_manager node

  • :timeout (Time)

    Explicit operation timeout

  • :wait_for_active_shards (String)

    Wait until the specified number of shards is active

  • :wait_for_nodes (String)

    Wait until the specified number of nodes is available

  • :wait_for_events (String)

    Wait until all currently queued events with the given priority are processed (options: immediate, urgent, high, normal, low, languid)

  • :wait_for_no_relocating_shards (Boolean)

    Whether to wait until there are no relocating shards in the cluster

  • :wait_for_no_initializing_shards (Boolean)

    Whether to wait until there are no initializing shards in the cluster

  • :wait_for_status (String)

    Wait until cluster is in a specific state (options: green, yellow, red)

  • :headers (Hash)

    Custom HTTP headers



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/opensearch/api/actions/cluster/health.rb', line 49

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_GET
  path   = if _index
             "_cluster/health/#{Utils.__listify(_index)}"
           else
             "_cluster/health"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#pending_tasks(arguments = {}) ⇒ Object

Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :local (Boolean)

    Return local information, do not retrieve the state from cluster_manager node (default: false)

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Specify timeout for connection to master

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :headers (Hash)

    Custom HTTP headers



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/opensearch/api/actions/cluster/pending_tasks.rb', line 40

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_GET
  path   = "_cluster/pending_tasks"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#post_voting_config_exclusions(arguments = {}) ⇒ Object

Updates the cluster voting config exclusions by node ids or node names.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :node_ids (String)

    A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names.

  • :node_names (String)

    A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids.

  • :timeout (Time)

    Explicit operation timeout

  • :headers (Hash)

    Custom HTTP headers



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb', line 39

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_POST
  path   = "_cluster/voting_config_exclusions"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#put_component_template(arguments = {}) ⇒ Object

Creates or updates a component template

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :name (String)

    The name of the template

  • :create (Boolean)

    Whether the index template should only be added if new or can also replace an existing one

  • :timeout (Time)

    Explicit operation timeout

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Specify timeout for connection to master

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The template definition (Required)

Raises:

  • (ArgumentError)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/opensearch/api/actions/cluster/put_component_template.rb', line 42

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

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

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = OpenSearch::API::HTTP_PUT
  path   = "_component_template/#{Utils.__listify(_name)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#put_settings(arguments = {}) ⇒ Object

Updates the cluster settings.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :flat_settings (Boolean)

    Return settings in flat format (default: false)

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Explicit operation timeout for connection to master node

  • :cluster_manager_timeout (Time)

    Explicit operation timeout for connection to cluster_manager node

  • :timeout (Time)

    Explicit operation timeout

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The settings to be updated. Can be either ‘transient` or `persistent` (survives cluster restart). (Required)

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/opensearch/api/actions/cluster/put_settings.rb', line 41

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

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_PUT
  path   = "_cluster/settings"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#remote_info(arguments = {}) ⇒ Object

Returns the information about configured remote clusters.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/opensearch/api/actions/cluster/remote_info.rb', line 36

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_GET
  path   = "_remote/info"
  params = {}

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

#reroute(arguments = {}) ⇒ Object

Allows to manually change the allocation of individual shards in the cluster.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :dry_run (Boolean)

    Simulate the operation only and return the resulting state

  • :explain (Boolean)

    Return an explanation of why the commands can or cannot be executed

  • :retry_failed (Boolean)

    Retries allocation of shards that are blocked due to too many subsequent allocation failures

  • :metric (List)

    Limit the information returned to the specified metrics. Defaults to all but metadata (options: _all, blocks, metadata, nodes, routing_table, cluster_manager_node, version)

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Explicit operation timeout for connection to master node

  • :cluster_manager_timeout (Time)

    Explicit operation timeout for connection to cluster_manager node

  • :timeout (Time)

    Explicit operation timeout

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The definition of ‘commands` to perform (`move`, `cancel`, `allocate`)



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/opensearch/api/actions/cluster/reroute.rb', line 44

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

  arguments = arguments.clone

  method = OpenSearch::API::HTTP_POST
  path   = "_cluster/reroute"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#state(arguments = {}) ⇒ Object

Returns a comprehensive information about the state of the cluster.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :metric (List)

    Limit the information returned to the specified metrics (options: _all, blocks, metadata, nodes, routing_table, routing_nodes, master_node, version)

  • :index (List)

    A comma-separated list of index names; use ‘_all` or empty string to perform the operation on all indices

  • :local (Boolean)

    Return local information, do not retrieve the state from cluster_manager node (default: false)

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Specify timeout for connection to master

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :flat_settings (Boolean)

    Return settings in flat format (default: false)

  • :wait_for_metadata_version (Number)

    Wait for the metadata version to be equal or greater than the specified metadata version

  • :wait_for_timeout (Time)

    The maximum time to wait for wait_for_metadata_version before timing out

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :headers (Hash)

    Custom HTTP headers



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/opensearch/api/actions/cluster/state.rb', line 47

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

  arguments = arguments.clone

  _metric = arguments.delete(:metric)

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_GET
  path   = if _metric && _index
             "_cluster/state/#{Utils.__listify(_metric)}/#{Utils.__listify(_index)}"
           elsif _metric
             "_cluster/state/#{Utils.__listify(_metric)}"
           else
             "_cluster/state"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#stats(arguments = {}) ⇒ Object

Returns high-level overview of cluster statistics.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :node_id (List)

    A comma-separated list of node IDs or names to limit the returned information; use ‘_local` to return information from the node you’re connecting to, leave empty to get information from all nodes

  • :flat_settings (Boolean)

    Return settings in flat format (default: false)

  • :timeout (Time)

    Explicit operation timeout

  • :headers (Hash)

    Custom HTTP headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/opensearch/api/actions/cluster/stats.rb', line 39

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

  arguments = arguments.clone

  _node_id = arguments.delete(:node_id)

  method = OpenSearch::API::HTTP_GET
  path   = if _node_id
             "_cluster/stats/nodes/#{Utils.__listify(_node_id)}"
           else
             "_cluster/stats"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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