Disable User API

edit

Execution

edit

Disabling a user can be performed using the security().disableUser() method:

DisableUserRequest request = new DisableUserRequest("disable_user", RefreshPolicy.NONE);
boolean response = client.security().disableUser(request, RequestOptions.DEFAULT);

Response

edit

The returned Boolean indicates the request status.

Asynchronous Execution

edit

This request can be executed asynchronously:

client.security().disableUserAsync(request, RequestOptions.DEFAULT, listener); 

The DisableUser request to execute and the ActionListener to use when the execution completes.

The asynchronous method does not block and returns immediately. Once the request has completed the ActionListener is called back using the onResponse method if the execution successfully completed or using the onFailure method if it failed.

A typical listener for a Boolean looks like:

DisableUserRequest request = new DisableUserRequest("disable_user", RefreshPolicy.NONE);
ActionListener<Boolean> listener = new ActionListener<Boolean>() {
    @Override
    public void onResponse(Boolean response) {
        
    }

    @Override
    public void onFailure(Exception e) {
        
    }
};

Called when the execution is successfully completed. The response is provided as an argument.

Called in case of failure. The raised exception is provided as an argument.