UserManager

class UserManager(core: Core, httpClient: CouchbaseHttpClient)

Samples

import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.manager.user.Role
import com.couchbase.client.kotlin.manager.user.User
fun main() { 
   //sampleStart 
   // Create a new user
cluster.users.upsertUser(
    User(
        username = "alice",
        password = "swordfish",
        roles = setOf(Role("data_reader", bucket = "*"))
    )
) 
   //sampleEnd
}
import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.manager.user.Role
import com.couchbase.client.kotlin.manager.user.User
fun main() { 
   //sampleStart 
   // 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 = "*"))
) 
   //sampleEnd
}
import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.manager.user.Role
import com.couchbase.client.kotlin.manager.user.User
fun main() { 
   //sampleStart 
   // 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")
) 
   //sampleEnd
}

Constructors

Link copied to clipboard
fun UserManager(core: Core, httpClient: CouchbaseHttpClient)

Functions

Link copied to clipboard
suspend fun changePassword(newPassword: String, common: CommonOptions = CommonOptions.Default)

Changes the password for the currently authenticated user.

Link copied to clipboard
@SinceCouchbase(value = "6.5")
suspend fun dropGroup(groupName: String, common: CommonOptions = CommonOptions.Default)
Link copied to clipboard
suspend fun dropUser(username: String, common: CommonOptions = CommonOptions.Default)
Link copied to clipboard
@SinceCouchbase(value = "6.5")
suspend fun getAllGroups(common: CommonOptions = CommonOptions.Default): List<Group>
Link copied to clipboard
suspend fun getAllUsers(common: CommonOptions = CommonOptions.Default): List<UserAndMetadata>
Link copied to clipboard
@SinceCouchbase(value = "6.5")
suspend fun getGroup(groupName: String, common: CommonOptions = CommonOptions.Default): Group
Link copied to clipboard
suspend fun getRoles(common: CommonOptions = CommonOptions.Default): List<RoleAndDescription>

Returns all roles supported by the Couchbase Server cluster.

Link copied to clipboard
suspend fun getUser(username: String, domain: AuthDomain = AuthDomain.LOCAL, common: CommonOptions = CommonOptions.Default): UserAndMetadata
Link copied to clipboard
@SinceCouchbase(value = "6.5")
suspend fun upsertGroup(group: Group, common: CommonOptions = CommonOptions.Default)
Link copied to clipboard
suspend fun upsertUser(user: User, common: CommonOptions = CommonOptions.Default)