SDK
SDK Dart v2.x
2

createRole #

Creates a new role.


Future<KuzzleRole> createRole(String id, 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 wait_for, Kuzzle will not respond until the created role is indexed
force
bool

(null)
If set to true, creates 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.createRole(
  '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] }  } }
*/