Expand example in HLRC put-role docs (#82139)

This expands the example in the High Level Rest Client's Put Role
documentation to include an example of creating a role with index
privileges, include FLS and DLS Relates: #81354
This commit is contained in:
Tim Vernum 2021-12-30 20:39:59 +11:00 committed by GitHub
parent cf8efe77df
commit bbd504275a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1462,6 +1462,14 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
final Role role = Role.builder() final Role role = Role.builder()
.name("testPutRole") .name("testPutRole")
.clusterPrivileges(randomSubsetOf(1, Role.ClusterPrivilegeName.ALL_ARRAY)) .clusterPrivileges(randomSubsetOf(1, Role.ClusterPrivilegeName.ALL_ARRAY))
.indicesPrivileges(IndicesPrivileges.builder()
.indices("my-index-*")
.allowRestrictedIndices(false)
.privileges(Role.IndexPrivilegeName.READ)
.grantedFields("*")
.deniedFields("secret_field")
.query("{ \"term\": { \"public\": true } }")
.build())
.build(); .build();
final PutRoleRequest request = new PutRoleRequest(role, RefreshPolicy.NONE); final PutRoleRequest request = new PutRoleRequest(role, RefreshPolicy.NONE);
// end::put-role-request // end::put-role-request