User Manager
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
Functions
Link copied to clipboard
@SinceCouchbase(value = "6.5" )
Content copied to clipboard
Link copied to clipboard
suspend fun dropUser(username: String, common: CommonOptions = CommonOptions.Default)
Content copied to clipboard
Link copied to clipboard
@SinceCouchbase(value = "6.5" )
Content copied to clipboard
Link copied to clipboard
suspend fun getAllUsers(common: CommonOptions = CommonOptions.Default): List<UserAndMetadata>
Content copied to clipboard
Link copied to clipboard
@SinceCouchbase(value = "6.5" )
Content copied to clipboard
Link copied to clipboard
suspend fun getRoles(common: CommonOptions = CommonOptions.Default): List<RoleAndDescription>
Content copied to clipboard
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
Content copied to clipboard
Link copied to clipboard
@SinceCouchbase(value = "6.5" )
Content copied to clipboard
Link copied to clipboard
suspend fun upsertUser(user: User, common: CommonOptions = CommonOptions.Default)
Content copied to clipboard