def invalidate_token(
        self,
        *,
        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,
        realm_name: t.Optional[str] = None,
        refresh_token: t.Optional[str] = None,
        token: t.Optional[str] = None,
        username: t.Optional[str] = None,
        body: t.Optional[t.Dict[str, t.Any]] = None,
    ) -> ObjectApiResponse[t.Any]:
        """
        .. raw:: html

          <p>Invalidate a token.</p>
          <p>The access tokens returned by the get token API have a finite period of time for which they are valid.
          After that time period, they can no longer be used.
          The time period is defined by the <code>xpack.security.authc.token.timeout</code> setting.</p>
          <p>The refresh tokens returned by the get token API are only valid for 24 hours.
          They can also be used exactly once.
          If you want to invalidate one or more access or refresh tokens immediately, use this invalidate token API.</p>
          <p>NOTE: While all parameters are optional, at least one of them is required.
          More specifically, either one of <code>token</code> or <code>refresh_token</code> parameters is required.
          If none of these two are specified, then <code>realm_name</code> and/or <code>username</code> need to be specified.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-invalidate-token>`_

        :param realm_name: The name of an authentication realm. This parameter cannot
            be used with either `refresh_token` or `token`.
        :param refresh_token: A refresh token. This parameter cannot be used if any of
            `refresh_token`, `realm_name`, or `username` are used.
        :param token: An access token. This parameter cannot be used if any of `refresh_token`,
            `realm_name`, or `username` are used.
        :param username: The username of a user. This parameter cannot be used with either
            `refresh_token` or `token`.
        """
        __path_parts: t.Dict[str, str] = {}
        __path = "/_security/oauth2/token"
        __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 realm_name is not None:
                __body["realm_name"] = realm_name
            if refresh_token is not None:
                __body["refresh_token"] = refresh_token
            if token is not None:
                __body["token"] = token
            if username is not None:
                __body["username"] = username
        __headers = {"accept": "application/json", "content-type": "application/json"}
        return self.perform_request(  # type: ignore[return-value]
            "DELETE",
            __path,
            params=__query,
            headers=__headers,
            body=__body,
            endpoint_id="security.invalidate_token",
            path_parts=__path_parts,
        )

        .. raw:: html

          <p>Invalidate a token.</p>
          <p>The access tokens returned by the get token API have a finite period of time for which they are valid.
          After that time period, they can no longer be used.
          The time period is defined by the <code>xpack.security.authc.token.timeout</code> setting.</p>
          <p>The refresh tokens returned by the get token API are only valid for 24 hours.
          They can also be used exactly once.
          If you want to invalidate one or more access or refresh tokens immediately, use this invalidate token API.</p>
          <p>NOTE: While all parameters are optional, at least one of them is required.
          More specifically, either one of <code>token</code> or <code>refresh_token</code> parameters is required.
          If none of these two are specified, then <code>realm_name</code> and/or <code>username</code> need to be specified.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-invalidate-token>`_

        :param realm_name: The name of an authentication realm. This parameter cannot
            be used with either `refresh_token` or `token`.
        :param refresh_token: A refresh token. This parameter cannot be used if any of
            `refresh_token`, `realm_name`, or `username` are used.
        :param token: An access token. This parameter cannot be used if any of `refresh_token`,
            `realm_name`, or `username` are used.
        :param username: The username of a user. This parameter cannot be used with either
            `refresh_token` or `token`.
        
elasticsearch/_sync/client/security.py