SDK
SDK Android v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

searchRoles #

Search for security roles, optionally returning only the roles giving access to the provided controller names.


searchRoles(filters, [options], callback) #

ArgumentsTypeDescription
filtersJSON ObjectOptionally contains a "controllers" array listing the controller names used to filter searched roles
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Filters #

FilterTypeDescriptionDefault
controllersarrayretrieve only roles allowing access to the provided names[]

Options #

OptionTypeDescriptionDefault
fromnumberStarting offset0
queuablebooleanMake this request queuable or nottrue
sizenumberNumber of hits to return per page10

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
  ]
}