Delete Role Mapping API

edit

Execution

edit

Deletion of a role mapping can be performed using the security().deleteRoleMapping() method:

final DeleteRoleMappingRequest request = new DeleteRoleMappingRequest("mapping-example", RefreshPolicy.NONE);
final DeleteRoleMappingResponse response = client.security().deleteRoleMapping(request, RequestOptions.DEFAULT);

Response

edit

The returned DeleteRoleMappingResponse contains a single field, found. If the mapping is successfully found and deleted, found is set to true. Otherwise, found is set to false.

boolean isFound = response.isFound(); 

found is a boolean indicating whether the role mapping was found and deleted

Asynchronous Execution

edit

This request can be executed asynchronously using the security().deleteRoleMappingAsync() method:

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

The DeleteRoleMappingRequest 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 DeleteRoleMappingResponse looks like:

ActionListener<DeleteRoleMappingResponse> listener = new ActionListener<DeleteRoleMappingResponse>() {
    @Override
    public void onResponse(DeleteRoleMappingResponse 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