def scripts_painless_execute(
        self,
        *,
        context: t.Optional[
            t.Union[
                str,
                t.Literal[
                    "boolean_field",
                    "composite_field",
                    "date_field",
                    "double_field",
                    "filter",
                    "geo_point_field",
                    "ip_field",
                    "keyword_field",
                    "long_field",
                    "painless_test",
                    "score",
                ],
            ]
        ] = None,
        context_setup: t.Optional[t.Mapping[str, t.Any]] = 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,
        script: t.Optional[t.Mapping[str, t.Any]] = None,
        body: t.Optional[t.Dict[str, t.Any]] = None,
    ) -> ObjectApiResponse[t.Any]:
        """
        .. raw:: html

          <p>Run a script.</p>
          <p>Runs a script and returns a result.
          Use this API to build and test scripts, such as when defining a script for a runtime field.
          This API requires very few dependencies and is especially useful if you don't have permissions to write documents on a cluster.</p>
          <p>The API uses several <em>contexts</em>, which control how scripts are run, what variables are available at runtime, and what the return type is.</p>
          <p>Each context requires a script, but additional parameters depend on the context you're using for that script.</p>


        `<https://www.elastic.co/docs/reference/scripting-languages/painless/painless-api-examples>`_

        :param context: The context that the script should run in. NOTE: Result ordering
            in the field contexts is not guaranteed.
        :param context_setup: Additional parameters for the `context`. NOTE: This parameter
            is required for all contexts except `painless_test`, which is the default
            if no value is provided for `context`.
        :param script: The Painless script to run.
        """
        __path_parts: t.Dict[str, str] = {}
        __path = "/_scripts/painless/_execute"
        __query: t.Dict[str, t.Any] = {}
        __body: t.Dict[str, t.Any] = body if body is not None else {}
        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 not __body:
            if context is not None:
                __body["context"] = context
            if context_setup is not None:
                __body["context_setup"] = context_setup
            if script is not None:
                __body["script"] = script
        if not __body:
            __body = None  # type: ignore[assignment]
        __headers = {"accept": "application/json"}
        if __body is not None:
            __headers["content-type"] = "application/json"
        return self.perform_request(  # type: ignore[return-value]
            "POST",
            __path,
            params=__query,
            headers=__headers,
            body=__body,
            endpoint_id="scripts_painless_execute",
            path_parts=__path_parts,
        )

        .. raw:: html

          <p>Run a script.</p>
          <p>Runs a script and returns a result.
          Use this API to build and test scripts, such as when defining a script for a runtime field.
          This API requires very few dependencies and is especially useful if you don't have permissions to write documents on a cluster.</p>
          <p>The API uses several <em>contexts</em>, which control how scripts are run, what variables are available at runtime, and what the return type is.</p>
          <p>Each context requires a script, but additional parameters depend on the context you're using for that script.</p>


        `<https://www.elastic.co/docs/reference/scripting-languages/painless/painless-api-examples>`_

        :param context: The context that the script should run in. NOTE: Result ordering
            in the field contexts is not guaranteed.
        :param context_setup: Additional parameters for the `context`. NOTE: This parameter
            is required for all contexts except `painless_test`, which is the default
            if no value is provided for `context`.
        :param script: The Painless script to run.
        
elasticsearch/_sync/client/__init__.py