SDK
SDK Java v2.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) #

ArgumentsTypeDescription
filtersJSON ObjectSearch query
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Options #

OptionTypeDescriptionDefault
fromnumberStarting offset0
queuablebooleanMake this request queuable or nottrue
scrollstringStart a scroll session, with a time to live equals to this parameter's value following the Elastisearch time formatundefined
sizeintegerNumber of hits to return per page10

Filters #

FilterTypeDescriptionDefault
rolesarrayContains an array roles with a list of role id[]

Callback Response #

Returns a JSON Object

Usage #

// optional: search only for profiles referring the listed roles
JSONObject filters = new JSONObject()
  .put("roles", new JSONArray().put("myrole").put("admin"));
// optional: result pagination configuration
Options options = new Options();
options.setFrom((long) 0);
options.setSize((long) 42);
options.setScroll("1m");
kuzzle
  .security
  .searchProfiles(filters, options, new ResponseListener<SecurityDocumentList>() {
    @Override
    public void onSuccess(SecurityDocumentList profiles) {
      // Contains a profiles list
      for(Profile profile : profiles.getDocuments()) {
      }
      // Total number of profiles, regardless of pagination
      long total = profiles.getTotal();
      // Available only if a "scroll" option has been provided
      String scrollId = profiles.getScroll()
    }
    @Override
    public void onError(JSONObject error) {
    }
  });

Callback response:

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