# Shutdown

class elasticsearch.client.ShutdownClient

  To use this client, access `client.shutdown` from an `Elasticsearch` client. For example:

      from elasticsearch import Elasticsearch

      # Create the client instance
      client = Elasticsearch(...)
      # Use the shutdown client
      client.shutdown.<method>(...)

  delete_node(*, node_id, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None)

    Cancel node shutdown preparations.

    Remove a node from the shutdown list so it can resume normal operations. You must explicitly clear the shutdown request when a node rejoins the cluster or when a node has permanently left the cluster. Shutdown requests are never removed automatically by Elasticsearch.

    NOTE: This feature is designed for indirect use by Elastic Cloud, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.

    If the operator privileges feature is enabled, you must be an operator to use this API.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-shutdown-delete-node

    Parameters:

      - node_id (str) – The node id of node to be removed from the shutdown state

      - master_timeout (str | Literal[-1] | ~typing.Literal[0] | None) – 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.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  get_node(*, node_id=None, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None)

    Get the shutdown status.

    Get information about nodes that are ready to be shut down, have shut down preparations still in progress, or have stalled. The API returns status information for each part of the shut down process.

    NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.

    If the operator privileges feature is enabled, you must be an operator to use this API.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-shutdown-get-node

    Parameters:

      - node_id (str | Sequence[str] | None) – Comma-separated list of nodes for which to retrieve the shutdown status

      - master_timeout (str | Literal[-1] | ~typing.Literal[0] | None) – 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.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  put_node(*, node_id, reason=None, type=None, allocation_delay=None, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, target_node_name=None, timeout=None, body=None)

    Prepare a node to be shut down.

    NOTE: This feature is designed for indirect use by Elastic Cloud, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.

    If you specify a node that is offline, it will be prepared for shut down when it rejoins the cluster.

    If the operator privileges feature is enabled, you must be an operator to use this API.

    The API migrates ongoing tasks and index shards to other nodes as needed to prepare a node to be restarted or shut down and removed from the cluster. This ensures that Elasticsearch can be stopped safely with minimal disruption to the cluster.

    You must specify the type of shutdown: `restart`, `remove`, or `replace`. If a node is already being prepared for shutdown, you can use this API to change the shutdown type.

    IMPORTANT: This API does NOT terminate the Elasticsearch process. Monitor the node shutdown status to determine when it is safe to stop Elasticsearch.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-shutdown-put-node

    Parameters:

      - node_id (str) – The node identifier. This parameter is not validated against the cluster’s active nodes. This enables you to register a node for shut down while it is offline. No error is thrown if you specify an invalid node ID.

      - reason (str | None) – A human-readable reason that the node is being shut down. This field provides information for other cluster operators; it does not affect the shut down process.

      - type (str | Literal['remove', 'replace', 'restart'] | None) – Valid values are restart, remove, or replace. Use restart when you need to temporarily shut down a node to perform an upgrade, make configuration changes, or perform other maintenance. Because the node is expected to rejoin the cluster, data is not migrated off of the node. Use remove when you need to permanently remove a node from the cluster. The node is not marked ready for shutdown until data is migrated off of the node Use replace to do a 1:1 replacement of a node with another node. Certain allocation decisions will be ignored (such as disk watermarks) in the interest of true replacement of the source node with the target node. During a replace-type shutdown, rollover and index creation may result in unassigned shards, and shrink may fail until the replacement is complete.

      - allocation_delay (str | None) – Only valid if type is restart. Controls how long Elasticsearch will wait for the node to restart and join the cluster before reassigning its shards to other nodes. This works the same as delaying allocation with the index.unassigned.node_left.delayed_timeout setting. If you don’t specify a restart allocation delay, a default value of 5 minutes will be used. If both a restart allocation delay and an index-level allocation delay are configured, the longer of the two is used.

      - master_timeout (str | Literal[-1] | ~typing.Literal[0] | None) – The 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.

      - target_node_name (str | None) – Only valid if type is replace. Specifies the name of the node that is replacing the node being shut down. Shards from the shut down node are only allowed to be allocated to the target node, and no other data will be allocated to the target node. During relocation of data certain allocation rules are ignored, such as disk watermarks or user attribute filtering rules.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]