Cluster Client

class opensearchpy.client.cluster.ClusterClient(client)[source]

Bases: NamespacedClient

Parameters:

client (Any) –

allocation_explain(body=None, params=None, headers=None)[source]

Provides explanations for shard allocations in the cluster.

Parameters:
  • body (Any) – The index, shard, and primary flag to explain. Empty means ‘explain the first unassigned shard’

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • include_disk_info – If true, returns information about disk usage and shard sizes. Default is false.

  • include_yes_decisions – If true, returns YES decisions in explanation. Default is false.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • body

  • params (Any) –

  • headers (Any) –

Return type:

Any

delete_component_template(name, params=None, headers=None)[source]

Deletes a component template.

Parameters:
  • name (Any) – Name of the component template to delete. Wildcard (*) expressions are supported.

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Period to wait for a response.If no response is received before the timeout expires, the request fails and returns an error.

  • name

  • params (Any) –

  • headers (Any) –

Return type:

Any

delete_decommission_awareness(params=None, headers=None)[source]

Delete any existing decommission.

Parameters:
  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • params (Any) –

  • headers (Any) –

Return type:

Any

delete_voting_config_exclusions(params=None, headers=None)[source]

Clears cluster voting config exclusions.

Parameters:
  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • wait_for_removal – Specifies whether to wait for all excluded nodes to be removed from thecluster before clearing the voting configuration exclusions list.Defaults to true, meaning that all excluded nodes must be removed fromthe cluster before this API takes any action. If set to false then thevoting configuration exclusions list is cleared even if some excludednodes are still in the cluster. Default is True.

  • params (Any) –

  • headers (Any) –

Return type:

Any

delete_weighted_routing(params=None, headers=None)[source]

Delete weighted shard routing weights.

Parameters:
  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • params (Any) –

  • headers (Any) –

Return type:

Any

exists_component_template(name, params=None, headers=None)[source]

Returns information about whether a particular component template exist.

Parameters:
  • name (Any) – Name of the component template to check existence of. Wildcard (*) expressions are supported.

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • local – If true, the request retrieves information from the local node only.Defaults to false, which means information is retrieved from the master node. Default is false.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node. If no response isreceived before the timeout expires, the request fails and returns anerror.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • name

  • params (Any) –

  • headers (Any) –

Return type:

Any

get_component_template(name=None, params=None, headers=None)[source]

Returns one or more component templates.

Parameters:
  • name (Any) – Name of the component template to retrieve. Wildcard (*) expressions are supported.

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • local – If true, the request retrieves information from the local node only.If false, information is retrieved from the master node. Default is false.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • name

  • params (Any) –

  • headers (Any) –

Return type:

Any

get_decommission_awareness(awareness_attribute_name, params=None, headers=None)[source]

Get details and status of decommissioned attribute.

Parameters:
  • awareness_attribute_name (Any) – Awareness attribute name.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • awareness_attribute_name

  • params (Any) –

  • headers (Any) –

Return type:

Any

get_settings(params=None, headers=None)[source]

Returns cluster settings.

Parameters:
  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • flat_settings – If true, returns settings in flat format. Default is false.

  • human – Whether to return human readable values for statistics.

  • include_defaults – If true, returns default cluster settings from the local node. Default is false.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Period to wait for a response.If no response is received before the timeout expires, the request fails and returns an error.

  • params (Any) –

  • headers (Any) –

Return type:

Any

get_weighted_routing(attribute, params=None, headers=None)[source]

Fetches weighted shard routing weights.

Parameters:
  • attribute (Any) – Awareness attribute name.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • attribute

  • params (Any) –

  • headers (Any) –

Return type:

Any

health(index=None, params=None, headers=None)[source]

Returns basic information about the health of the cluster.

Parameters:
  • index (Any) – Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported. To target all data streams and indices in a cluster, omit this parameter or use _all or *.

  • awareness_attribute – The awareness attribute for which the health is required.

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices are all, open, closed, hidden, none.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • level – Can be one of cluster, indices or shards. Controls the details level of the health information returned. Valid choices are cluster, indices, shards, awareness_attributes.

  • local – If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. Default is false.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

  • wait_for_active_shards – A number controlling to how many active shards to wait for, all to wait for all shards in the cluster to be active, or 0 to not wait. Valid choices are all, index-setting.

  • wait_for_events – Can be one of immediate, urgent, high, normal, low, languid. Wait until all currently queued events with the given priority are processed. Valid choices are immediate, urgent, high, normal, low, languid.

  • wait_for_no_initializing_shards – A boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard initializations. Defaults to false, which means it will not wait for initializing shards.

  • wait_for_no_relocating_shards – A boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard relocations. Defaults to false, which means it will not wait for relocating shards.

  • wait_for_nodes – The request waits until the specified number N of nodes is available. It also accepts >=N, <=N, >N and <N. Alternatively, it is possible to use ge(N), le(N), gt(N) and lt(N) notation.

  • wait_for_status – One of green, yellow or red. Will wait (until the timeout provided) until the status of the cluster changes to the one provided or better, i.e. green > yellow > red. By default, will not wait for any status. Valid choices are green, yellow, red.

  • index

  • params (Any) –

  • headers (Any) –

Return type:

Any

pending_tasks(params=None, headers=None)[source]

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:
  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • local – If true, the request retrieves information from the local node only.If false, information is retrieved from the master node. Default is false.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • params (Any) –

  • headers (Any) –

Return type:

Any

post_voting_config_exclusions(params=None, headers=None)[source]

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

Parameters:
  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • node_ids – A comma-separated list of the persistent ids of the nodes to excludefrom the voting configuration. If specified, you may not also specify node_names.

  • node_names – A comma-separated list of the names of the nodes to exclude from thevoting configuration. If specified, you may not also specify node_ids.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – When adding a voting configuration exclusion, the API waits for thespecified nodes to be excluded from the voting configuration beforereturning. If the timeout expires before the appropriate conditionis satisfied, the request fails and returns an error.

  • params (Any) –

  • headers (Any) –

Return type:

Any

put_component_template(name, body, params=None, headers=None)[source]

Creates or updates a component template.

Parameters:
  • name (Any) – Name of the component template to create. Opensearch includes the following built-in component templates: logs-mappings; ‘logs-settings`; metrics-mappings; metrics-settings;`synthetics- mapping`; synthetics-settings. Opensearch Agent uses these templates to configure backing indices for its data streams. If you use Opensearch Agent and want to overwrite one of these templates, set the version for your replacement template higher than the current version. If you don’t use Opensearch Agent and want to disable all built-in component and index templates, set stack.templates.enabled to false using the cluster update settings API.

  • body (Any) – The template definition

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • create – If true, this request cannot replace or update existing component templates. Default is false.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Operation timeout.

  • name

  • body

  • params (Any) –

  • headers (Any) –

Return type:

Any

put_decommission_awareness(awareness_attribute_name, awareness_attribute_value, params=None, headers=None)[source]

Decommissions an awareness attribute.

Parameters:
  • awareness_attribute_name (Any) – Awareness attribute name.

  • awareness_attribute_value (Any) – Awareness attribute value.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • awareness_attribute_name

  • awareness_attribute_value

  • params (Any) –

  • headers (Any) –

Return type:

Any

put_settings(body, params=None, headers=None)[source]

Updates the cluster settings.

Parameters:
  • body (Any) – The settings to be updated. Can be either transient or persistent (survives cluster restart).

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • flat_settings – Return settings in flat format. Default is false.

  • human – Whether to return human readable values for statistics.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Explicit operation timeout for connection to master node

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Explicit operation timeout

  • body

  • params (Any) –

  • headers (Any) –

Return type:

Any

put_weighted_routing(attribute, params=None, headers=None)[source]

Updates weighted shard routing weights.

Parameters:
  • attribute (Any) – Awareness attribute name.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • attribute

  • params (Any) –

  • headers (Any) –

Return type:

Any

remote_info(params=None, headers=None)[source]

Returns the information about configured remote clusters.

Parameters:
  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • params (Any) –

  • headers (Any) –

Return type:

Any

reroute(body=None, params=None, headers=None)[source]

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

Parameters:
  • body (Any) – The definition of commands to perform (move, cancel, allocate)

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • dry_run – If true, then the request simulates the operation only and returns the resulting state.

  • error_trace – Whether to include the stack trace of returned errors.

  • explain – If true, then the response contains an explanation of why the commands can or cannot be executed.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • human – Whether to return human readable values for statistics.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.

  • metric – Limits the information returned to the specified metrics.

  • pretty – Whether to pretty format the returned JSON response.

  • retry_failed – If true, then retries allocation of shards that are blocked due to too many subsequent allocation failures.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

  • body

  • params (Any) –

  • headers (Any) –

Return type:

Any

state(metric=None, index=None, params=None, headers=None)[source]

Returns a comprehensive information about the state of the cluster.

Parameters:
  • metric (Any) – Limit the information returned to the specified metrics

  • index (Any) – A comma-separated list of index names; use _all or empty string to perform the operation on all indices

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

  • cluster_manager_timeout – Operation timeout for connection to cluster-manager node.

  • error_trace – Whether to include the stack trace of returned errors.

  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices are all, open, closed, hidden, none.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • flat_settings – Return settings in flat format. Default is false.

  • human – Whether to return human readable values for statistics.

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

  • local – Return local information, do not retrieve the state from cluster-manager node. Default is false.

  • (Deprecated (master_timeout) – To promote inclusive language, use ‘cluster_manager_timeout’ instead.): Specify timeout for connection to master

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

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

  • wait_for_timeout – The maximum time to wait for wait_for_metadata_version before timing out

  • metric

  • index

  • params (Any) –

  • headers (Any) –

Return type:

Any

stats(node_id=None, params=None, headers=None)[source]

Returns high-level overview of cluster statistics.

Parameters:
  • node_id (Any) – Comma-separated list of node filters used to limit returned information. Defaults to all nodes in the cluster.

  • error_trace – Whether to include the stack trace of returned errors.

  • filter_path – Comma-separated list of filters used to reduce the response.

  • flat_settings – If true, returns settings in flat format. Default is false.

  • human – Whether to return human readable values for statistics.

  • pretty – Whether to pretty format the returned JSON response.

  • source – The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.

  • timeout – Period to wait for each node to respond.If a node does not respond before its timeout expires, the response does not include its stats.However, timed out nodes are included in the response’s _nodes.failed property. Defaults to no timeout.

  • node_id

  • params (Any) –

  • headers (Any) –

Return type:

Any