addPolicy

profile.addPolicy({
  'roleId': 'some role id',
  'restrictedTo': [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ]
});
JSONObject policy = new JSONObject()
  .put("roleId", "some role id")
  .put("restrictedTo", new JSONArray()
    .put(new JSONObject().put("index", "index1"))
    .put(new JSONObject()
      .put("index", "index2")
      .put("collections", new JSONArray().put("foo").put("bar"))
    )
  );

profile.addPolicy(policy);

// you may also add a role ID directly
profile.addPolicy("some role id");

Adds a role to the profile.


addPolicy(id)

ArgumentsTypeDescription
idstringUnique id of the new role to associate

addPolicy(policy)

ArgumentsTypeDescription
policyJSON Objectpolicy instance corresponding to the new associated role and its restrictions

Return value

Returns the Profile object to allow chaining calls.