updateRole

var roleDefinition = {
  controllers: {
    "read": {
      actions: {
        "get": true
      }
    }
  }
};

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .security
  .updateRole("role ID", roleDefinition, function (err, updatedRole) {
    // "updatedRole" is an instance of a Role object
  });

// Using promises (NodeJS)
kuzzle
  .security
  .updateRolePromise("profile ID", roleDefinition)
  .then(updatedRole => {
    // "updatedRole" is an instance of a Role object
  });
JSONObject roleDefinition = new JSONObject()
  .put("controllers", new JSONObject()
    .put("*", new JSONObject()
      .put("actions", new JSONObject()
        .put("*", true)
      )
    )
  )
);

kuzzle
  .security
  .updateRole("Role ID", roleDefinition, new ResponseListener<Role>() {
    @Override
    public void onSuccess(Role role) {

    }

    @Override
    public void onError(JSONObject error) {

    }
  });
<?php

use \Kuzzle\Kuzzle;
use \Kuzzle\Security\Role;

$roleId = 'myRole';
$roleDefinition = [
  'controllers' => [
    '*' => [
      'actions' => [
        '*' => true
      ]
    ]
  ]
];

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

try {
  $role = $security->updateRole($roleId, $roleDefinition);

  // $role instanceof Role
}
catch (ErrorException $e) {

}

Performs a partial update on an existing role.


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

ArgumentsTypeDescription
idstringUnique role identifier
contentJSON ObjectA plain JSON object representing the role
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 Role object