SDK
SDK Dart Null Safety v3.x
2

createOrReplaceProfile #

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


Future<KuzzleProfile> createOrReplaceProfile(
      String uid, List<Map<String, dynamic>> policies,
      {bool? waitForRefresh})

PropertyTypeDescription
id
String
Profile identifier
policies
List<Map<String, dynamic>>
Profile content
waitForRefresh
bool?

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

Return #

A Profile object representing the updated/created profile.

Usage #

final result = await kuzzle.security.createOrReplaceProfile(
  'myProfile',
  [
    {
      'roleId': 'default'
    },
    {
      'roleId': 'admin',
      'restrictedTo': [
        {
          'index': 'someindex',
          'collections': [
            'collection1',
            'collection2'
          ]
        }
      ]
    }
  ]
);
/*
Profile {
  _id: 'myProfile',
  policies:
    [ { roleId: 'default' },
      { roleId: 'admin', restrictedTo: [Array] } ] }
*/