Get Role Mappings APIedit

Executionedit

Retrieving a role mapping can be performed using the security().getRoleMappings() method and by setting role mapping name on GetRoleMappingsRequest:

final GetRoleMappingsRequest request = new GetRoleMappingsRequest("mapping-example-1");
final GetRoleMappingsResponse response = client.security().getRoleMappings(request, RequestOptions.DEFAULT);

Retrieving multiple role mappings can be performed using the security.getRoleMappings() method and by setting role mapping names on GetRoleMappingsRequest:

final GetRoleMappingsRequest request = new GetRoleMappingsRequest("mapping-example-1", "mapping-example-2");
final GetRoleMappingsResponse response = client.security().getRoleMappings(request, RequestOptions.DEFAULT);

Retrieving all role mappings can be performed using the security.getRoleMappings() method and with no role mapping name on GetRoleMappingsRequest:

final GetRoleMappingsRequest request = new GetRoleMappingsRequest();
final GetRoleMappingsResponse response = client.security().getRoleMappings(request, RequestOptions.DEFAULT);

Responseedit

The returned GetRoleMappingsResponse contains the list of role mapping(s).

List<ExpressionRoleMapping> mappings = response.getMappings();

Asynchronous Executionedit

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

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

The GetRoleMappingsRequest 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 GetRoleMappingsResponse looks like:

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