SDK
SDK Javascript v5.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
const filters = {
  controllers:  ['document']
};
// optional result pagination configuration
const options = {
  from: 0,
  size: 10
};
// Using callbacks (NodeJS or Web Browser)
kuzzle
  .security
  .searchRoles(filters, options, function(error, result) {
    // result is a JSON Object with the following properties:
    // {
    //   total: <number of found roles>,
    //   roles: [<Role object>, <Role object>, ...]
    // }
  });
// Using promises (NodeJS)
kuzzle
  .security
  .searchRolesPromise(filters, options)
  .then(result => {
    // result is a JSON Object with the following properties:
    // {
    //   total: <number of found roles>,
    //   roles: [<Role object>, <Role object>, ...]
    // }
  });

Callback response:

{
  "total": 124,
  "roles": [
    // array of Role
  ]
}