updateProfile

var policies = [
  {roleId: 'myrole'},
  {
    roleId: 'default', 
    restrictedTo: [
      {index: 'index1'}, 
      {index: 'index2', collections: ['foo', 'bar'] } 
    ] 
  }
];

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .security
  .updateProfile("profile ID", policies, function (err, updatedProfile) {

  });

// Using promises (NodeJS)
kuzzle
  .security
  .updateProfilePromise("profile ID", policies)
  .then(updatedProfile => {

  });
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"))
      )
    )
};

kuzzle
  .security
  .updateProfile("profile ID", policies, new ResponseListener<Profile>() {
    @Override
    public void onSuccess(Profile profile) {

    }

    @Override
    public void onError(JSONObject error) {

    }
  });
<?php

use \Kuzzle\Kuzzle;
use \Kuzzle\Security\Profile;

$profileId = 'myProfile';
$policies = [
  [
    'roleId' => 'myRole'
  ],
  [
    'roleId' => 'anonymous',
    'restrictedTo' => [
      ['index' => 'my-second-index', 'collection' => ['my-collection']]
    ]
  ]
];

$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();

try {
  $profile = $security->updateProfile($profileId, $policies);

  // $profile instanceof Profile
}
catch (ErrorException $e) {

}

Performs a partial update on an existing profile.


updateProfile(id, content, [options], [callback])

ArgumentsTypeDescription
idstringUnique role identifier
policiesarray of objectsList of policies to apply to this profile
optionsstring(Optional) Optional arguments
callbackfunction(Optional) Callback handling the response

Options

FilterTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the Security object to allow chaining.


Callback response

Resolves to an updated Profile object