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.

createProfile #

Create a new profile in Kuzzle.

There is a small delay between profile creation and its availability in our search layer (usually a couple of seconds).
That means that a profile that was just created might not be immediately returned by the searchProfiles function.


createProfile(id, content, [options], callback) #

ArgumentsTypeDescription
idstringUnique profile identifier
policiesarray of JSON objectsList of policies to apply to this profile
optionsstring(Optional) Optional arguments
callbackfunctionCallback handling the response

Options #

FilterTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue
replaceIfExistbooleanIf the same profile already exists: throw an error if sets to false. Replace the existing profile otherwisefalse
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above)undefined

Callback Response #

Returns a security Profile object.

Usage #

JSONObject[] policies = new JSONObject[]{
  new JSONObject().put("roleId", "myrole"),
  new JSONObject()
    .put("roleId", "default")
    .put("restrictedTo", new JSONArray()
      .put(new JSONObject().put("index", "index1"))
      .put(new JSONObject()
        .put("index", "index2")
        .put("collections",new JSONArray().put("foo").put("bar"))
      )
    )
};
Options opts = new Options().setReplaceIfExist(true);
kuzzle
  .security
  .createProfile("myprofile", policies, opts, new ResponseListener<Profile>() {
    @Override
    public void onSuccess(Profile profile) {
    }
    @Override
    public void onError(JSONObject error) {
    }
  });