SDK
SDK Dart v2.x
2

createOrReplaceRole #

Creates a new role or, if the provided role identifier already exists, replaces it.


Future<KuzzleRole> createOrReplaceRole(
      String uid, Map<String, dynamic> controllers,
      {bool waitForRefresh, bool force})

PropertyTypeDescription
id
String
Role identifier
controllers
Map<String, dynamic>
Role definition
waitForRefresh
bool

(null)
If set to true, Kuzzle will not respond until the created/replaced role is indexed
force
bool

(null)
If set to true, creates or replaces the role even if it gives access to non-existent plugins API routes.

Return #

A Role object representing the created/replaced role.

Usage #

final result = await kuzzle.security.createOrReplaceRole(
  'read-only',
  {
    '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
      }
    }
  }
);
/*
Role {
  _id: 'read-only',
  controllers:
    { auth: { actions: [Object] },
      collection: { actions: [Object] },
      document: { actions: [Object] },
      index: { actions: [Object] }  } }
*/