searchRoles #
Search for security roles, optionally returning only the roles giving access to the provided controller names.
searchRoles(filters, [options], callback) #
Arguments | Type | Description |
---|---|---|
filters | JSON Object | Optionally contains a "controllers" array listing the controller names used to filter searched roles |
options | JSON Object | Optional parameters |
callback | function | Callback handling the response |
Filters #
Filter | Type | Description | Default |
---|---|---|---|
controllers | array | retrieve only roles allowing access to the provided names | [] |
Options #
Option | Type | Description | Default |
---|---|---|---|
from | number | Starting offset | 0 |
queuable | boolean | Make this request queuable or not | true |
size | number | Number of hits to return per page | 10 |
Callback Response #
Return a JSON Object
Usage #
// optional: retrieve only roles allowing access to the
// provided controller names
JSONObject filter = new JSONObject()
.put("controllers", new JSONArray()
.put("document")
.put("security")
);
// optional: result pagination configuration
Options options = new Options();
options.setFrom((long) 0);
options.setSize((long) 42);
options.setScroll("1m");
kuzzle
.security
.searchRoles(filter, options, new ResponseListener<SecurityDocumentList>() {
@Override
public void onSuccess(SecurityDocumentList roles) {
// roles.getDocuments() returns a roles list
for(Role role : roles.getDocuments()) {
}
// roles.getTotal() returns the number of matched roles, regardless of pagination
roles.getTotal();
}
});
Callback response:
{
"total": 124,
"roles": [
// array of Role
]
}
Edit this page on Github(opens new window)