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.

searchProfiles #

Search for security profiles, optionally returning only those linked to the provided list of security roles.


searchProfiles(filters, [options], callback) #

Arguments Type Description
filters JSON Object Search query
options JSON Object Optional parameters
callback function Callback handling the response

Options #

Option Type Description Default
from number Starting offset 0
queuable boolean Make this request queuable or not true
scroll string Start a scroll session, with a time to live equals to this parameter's value following the Elastisearch time format undefined
size integer Number of hits to return per page 10

Filters #

Filter Type Description Default
roles array Contains an array roles with a list of role id []

Callback Response #

Returns a JSON Object

Usage #

Copied to clipboard!
// optional: search only for profiles referring the listed roles
const filters = {
  roles:  ['myrole', 'admin']
};
// optional: result pagination configuration
const options = {
  from: 0,
  size: 10,
  scroll: '1m'
};
// Using callbacks (NodeJS or Web Browser)
kuzzle
  .security
  .searchProfiles(filters, options, function (error, result) {
    // result is a JSON Object with the following properties:
    // {
    //   total: <number of found profiles>,
    //   profiles: [<Profile object>, <Profile object>, ...],
    //   scrollId: "<only if a 'scroll' parameter has been passed in the options>"
    // }
  });
// Using promises (NodeJS)
kuzzle
  .security
  .searchProfilesPromise(filters, options)
  .then(result => {
    // result is a JSON Object with the following properties:
    // {
    //   total: <number of found profiles>,
    //   profiles: [<Profile object>, <Profile object>, ...],
    //   scrollId: "<only if a 'scroll' parameter has been passed in the options>"
    // }
  });

Callback response:

Copied to clipboard!
{
  "total": 124,
  "profiles": [
    // array of Profile objects
  ],
  // only if a scroll parameter has been provided
  "scrollId": "<scroll identifier>"
}