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

Copied to clipboard!
// 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:

Copied to clipboard!
{
  "total": 124,
  "roles": [
    // array of Role
  ]
}