upsert User
Samples
// Create a new user
cluster.users.upsertUser(
User(
username = "alice",
password = "swordfish",
roles = setOf(Role("data_reader", bucket = "*"))
)
)Content copied to clipboard
// Add a new role to an existing user
// (must get existing user first, otherwise existing values are clobbered)
val user = cluster.users.getUser("alice").user
cluster.users.upsertUser(
user.copy(roles = user.roles + Role("data_writer", bucket = "*"))
)Content copied to clipboard
// Change the password of an existing user
// (must get existing user first, otherwise existing values are clobbered)
val user = cluster.users.getUser("alice").user
cluster.users.upsertUser(
user.copy(password = "correct horse battery staple")
)Content copied to clipboard