updateRole

Performs a partial update on an existing role.


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

Arguments Type Description
id string Unique role identifier
content JSON Object A plain JSON object representing the role
options string (Optional) Optional arguments
callback function (Optional) Callback handling the response

Options

Filter Type Description Default
queuable boolean Make this request queuable or not true
refresh string If set to wait_for, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) undefined

Return Value

Returns the Security object to allow chaining.


Callback Response

Returns an updated Role object.

Usage

Copied to clipboard!

<?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) {

}