Class: Couchbase::Management::UserManager
- Inherits:
-
Object
- Object
- Couchbase::Management::UserManager
- Defined in:
- lib/couchbase/management/user_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/management/user_manager.rb
Defined Under Namespace
Classes: ChangePasswordOptions, DropGroupOptions, DropUserOptions, GetAllGroupsOptions, GetAllUsersOptions, GetGroupOptions, GetRolesOptions, GetUserOptions, UpsertGroupOptions, UpsertUserOptions
Instance Method Summary collapse
-
#change_password(new_password, options = ChangePasswordOptions.new) ⇒ Object
Changes the password of the currently authenticated user.
-
#drop_group(group_name, options = DropGroupOptions.new) ⇒ Object
Removes a group.
-
#drop_user(username, options = DropUserOptions.new) ⇒ Object
Removes a user.
-
#get_all_groups(options = GetAllGroupsOptions.new) ⇒ Array<Group>
Gets all groups.
-
#get_all_users(options = GetAllUsersOptions.new) ⇒ Array<UserAndMetadata>
Gets all users.
-
#get_group(group_name, options = GetGroupOptions.new) ⇒ Group
Gets a group.
-
#get_roles(options = GetRolesOptions.new) ⇒ Array<RoleAndDescription>
Gets all roles supported by the server.
-
#get_user(username, options = GetUserOptions.new) ⇒ UserAndMetadata
Get a user.
-
#initialize(backend) ⇒ UserManager
constructor
A new instance of UserManager.
-
#upsert_group(group, options = UpsertGroupOptions.new) ⇒ Object
Creates or updates a group.
-
#upsert_user(user, options = UpsertUserOptions.new) ⇒ Object
Creates or updates a user.
Constructor Details
#initialize(backend) ⇒ UserManager
Returns a new instance of UserManager.
27 28 29 |
# File 'lib/couchbase/management/user_manager.rb', line 27 def initialize(backend) @backend = backend end |
Instance Method Details
#change_password(new_password, options = ChangePasswordOptions.new) ⇒ Object
Changes the password of the currently authenticated user
111 112 113 |
# File 'lib/couchbase/management/user_manager.rb', line 111 def change_password(new_password, = ChangePasswordOptions.new) @backend.change_password(new_password, .timeout) end |
#drop_group(group_name, options = DropGroupOptions.new) ⇒ Object
Removes a group
167 168 169 |
# File 'lib/couchbase/management/user_manager.rb', line 167 def drop_group(group_name, = DropGroupOptions.new) @backend.group_drop(group_name, .timeout) end |
#drop_user(username, options = DropUserOptions.new) ⇒ Object
Removes a user
83 84 85 |
# File 'lib/couchbase/management/user_manager.rb', line 83 def drop_user(username, = DropUserOptions.new) @backend.user_drop(.domain, username, .timeout) end |
#get_all_groups(options = GetAllGroupsOptions.new) ⇒ Array<Group>
Gets all groups
133 134 135 136 |
# File 'lib/couchbase/management/user_manager.rb', line 133 def get_all_groups( = GetAllGroupsOptions.new) resp = @backend.group_get_all(.timeout) resp.map { |entry| extract_group(entry) } end |
#get_all_users(options = GetAllUsersOptions.new) ⇒ Array<UserAndMetadata>
Gets all users
48 49 50 51 |
# File 'lib/couchbase/management/user_manager.rb', line 48 def get_all_users( = GetAllUsersOptions.new) resp = @backend.user_get_all(.domain, .timeout) resp.map { |entry| extract_user(entry) } end |
#get_group(group_name, options = GetGroupOptions.new) ⇒ Group
Gets a group
123 124 125 126 |
# File 'lib/couchbase/management/user_manager.rb', line 123 def get_group(group_name, = GetGroupOptions.new) resp = @backend.group_get(group_name, .timeout) extract_group(resp) end |
#get_roles(options = GetRolesOptions.new) ⇒ Array<RoleAndDescription>
Gets all roles supported by the server
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/couchbase/management/user_manager.rb', line 92 def get_roles( = GetRolesOptions.new) resp = @backend.role_get_all(.timeout) resp.map do |r| RoleAndDescription.new do |role| role.name = r[:name] role.display_name = r[:display_name] role.description = r[:description] role.bucket = r[:bucket] role.scope = r[:scope] role.collection = r[:collection] end end end |
#get_user(username, options = GetUserOptions.new) ⇒ UserAndMetadata
Get a user
40 41 42 43 |
# File 'lib/couchbase/management/user_manager.rb', line 40 def get_user(username, = GetUserOptions.new) resp = @backend.user_get(.domain, username, .timeout) extract_user(resp) end |
#upsert_group(group, options = UpsertGroupOptions.new) ⇒ Object
Creates or updates a group
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/couchbase/management/user_manager.rb', line 145 def upsert_group(group, = UpsertGroupOptions.new) @backend.group_upsert({ name: group.name, description: group.description, ldap_group_reference: group.ldap_group_reference, roles: group.roles.map do |role| { name: role.name, bucket: role.bucket, scope: role.scope, collection: role.collection, } end, }, .timeout) end |
#upsert_user(user, options = UpsertUserOptions.new) ⇒ Object
Creates or updates a user
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/couchbase/management/user_manager.rb', line 59 def upsert_user(user, = UpsertUserOptions.new) @backend.user_upsert( .domain, { username: user.username, display_name: user.display_name, groups: user.groups, password: user.password, roles: user.roles.map do |role| { name: role.name, bucket: role.bucket, scope: role.scope, collection: role.collection, } end, }, .timeout ) end |