SDK
SDK Javascript v7.x
2

updateRole #

Updates a security role definition.

Note: partial updates are not supported for roles, this API route will replace the entire role content with the provided one.


updateRole(id, body, [options]);

PropertyTypeDescription
id
string
Role identifier
body
object
Role definition content
options
object
Query options

body #

PropertyTypeDescription
controllers
object
Role definition

options #

PropertyType
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again
refresh
boolean

(false)
If set to wait_for, Kuzzle will not respond until the updated role is indexed
force
boolean

(false)
If set to true, updates the role even if it gives access to non-existent plugins API routes
timeout
number

(-1)
Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely
triggerEvents
boolean

(false)
If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop.
Available since Kuzzle 2.31.0

Resolves #

A Role object representing the updated role.

Usage #

try {
  const response = await kuzzle.security.updateRole('read-only', {
    controllers: {
      auth: {
        actions: {
          getCurrentUser: true,
          getMyCredentials: true,
          getMyRights: true,
          logout: true
        }
      },
      collection: {
        actions: {
          getMapping: true,
          list: true
        }
      },
      document: {
        actions: {
          count: true,
          get: true,
          mGet: true,
          scroll: true,
          search: true
        }
      },
      index: {
        actions: {
          list: true
        }
      }
    }
  });
  console.log(response);
  /*
  Role {
    _id: 'read-only',
    controllers:
      { auth: { actions: [Object] },
        collection: { actions: [Object] },
        document: { actions: [Object] },
        index: { actions: [Object] }  } }
   */
} catch (e) {
  console.error(e);
}