Enable User API

Execution

Enabling a disabled user can be performed using the security().enableUser() method:

EnableUserRequest request = new EnableUserRequest("enable_user", RefreshPolicy.NONE);
boolean response = client.security().enableUser(request, RequestOptions.DEFAULT);

Response

The returned Boolean indicates the request status.

Asynchronous Execution

This request can be executed asynchronously:

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

The EnableUser 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:

EnableUserRequest request = new EnableUserRequest("enable_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.