async def set_upgrade_mode(
        self,
        *,
        enabled: t.Optional[bool] = None,
        error_trace: t.Optional[bool] = None,
        filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        human: t.Optional[bool] = None,
        pretty: t.Optional[bool] = None,
        timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
    ) -> ObjectApiResponse[t.Any]:
        """
        .. raw:: html

          <p>Set upgrade_mode for ML indices.
          Sets a cluster wide upgrade_mode setting that prepares machine learning
          indices for an upgrade.
          When upgrading your cluster, in some circumstances you must restart your
          nodes and reindex your machine learning indices. In those circumstances,
          there must be no machine learning jobs running. You can close the machine
          learning jobs, do the upgrade, then open all the jobs again. Alternatively,
          you can use this API to temporarily halt tasks associated with the jobs and
          datafeeds and prevent new jobs from opening. You can also use this API
          during upgrades that do not require you to reindex your machine learning
          indices, though stopping jobs is not a requirement in that case.
          You can see the current value for the upgrade_mode setting by using the get
          machine learning info API.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-set-upgrade-mode>`_

        :param enabled: When `true`, it enables `upgrade_mode` which temporarily halts
            all job and datafeed tasks and prohibits new job and datafeed tasks from
            starting.
        :param timeout: The time to wait for the request to be completed.
        """
        __path_parts: t.Dict[str, str] = {}
        __path = "/_ml/set_upgrade_mode"
        __query: t.Dict[str, t.Any] = {}
        if enabled is not None:
            __query["enabled"] = enabled
        if error_trace is not None:
            __query["error_trace"] = error_trace
        if filter_path is not None:
            __query["filter_path"] = filter_path
        if human is not None:
            __query["human"] = human
        if pretty is not None:
            __query["pretty"] = pretty
        if timeout is not None:
            __query["timeout"] = timeout
        __headers = {"accept": "application/json"}
        return await self.perform_request(  # type: ignore[return-value]
            "POST",
            __path,
            params=__query,
            headers=__headers,
            endpoint_id="ml.set_upgrade_mode",
            path_parts=__path_parts,
        )

        .. raw:: html

          <p>Set upgrade_mode for ML indices.
          Sets a cluster wide upgrade_mode setting that prepares machine learning
          indices for an upgrade.
          When upgrading your cluster, in some circumstances you must restart your
          nodes and reindex your machine learning indices. In those circumstances,
          there must be no machine learning jobs running. You can close the machine
          learning jobs, do the upgrade, then open all the jobs again. Alternatively,
          you can use this API to temporarily halt tasks associated with the jobs and
          datafeeds and prevent new jobs from opening. You can also use this API
          during upgrades that do not require you to reindex your machine learning
          indices, though stopping jobs is not a requirement in that case.
          You can see the current value for the upgrade_mode setting by using the get
          machine learning info API.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-set-upgrade-mode>`_

        :param enabled: When `true`, it enables `upgrade_mode` which temporarily halts
            all job and datafeed tasks and prohibits new job and datafeed tasks from
            starting.
        :param timeout: The time to wait for the request to be completed.
        
elasticsearch/_async/client/ml.py