WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Creating and updating a role mapping can be performed using the
final RoleMapperExpression rules = AnyRoleMapperExpression.builder() .addExpression(FieldRoleMapperExpression.ofUsername("*")) .addExpression(FieldRoleMapperExpression.ofGroups("cn=admins,dc=example,dc=com")) .build(); final PutRoleMappingRequest request = new PutRoleMappingRequest("mapping-example", true, Collections.singletonList("superuser"), Collections.emptyList(), rules, null, RefreshPolicy.NONE); final PutRoleMappingResponse response = client.security().putRoleMapping(request, RequestOptions.DEFAULT);
PutRoleMappingResponse contains a single field,
created. This field
serves as an indication if a role mapping was created or if an existing entry was updated.
This request can be executed asynchronously using the
The asynchronous method does not block and returns immediately. Once the request
has completed the
ActionListener is called back using the
if the execution successfully completed or using the
onFailure method if
A typical listener for a
PutRoleMappingResponse looks like: