Class: Couchbase::Management::UserManager
- Inherits:
-
Object
- Object
- Couchbase::Management::UserManager
- Defined in:
- lib/couchbase/management/user_manager.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/management/user_manager.rb more...
Defined Under Namespace
Classes: DropGroupOptions, DropUserOptions, GetAllGroupsOptions, GetAllUsersOptions, GetGroupOptions, GetRolesOptions, GetUserOptions, UpsertGroupOptions, UpsertUserOptions
Instance Method Summary collapse
-
#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.
25 26 27 |
# File 'lib/couchbase/management/user_manager.rb', line 25 def initialize(backend) @backend = backend end |
Instance Method Details
#drop_group(group_name, options = DropGroupOptions.new) ⇒ Object
Removes a group
156 157 158 |
# File 'lib/couchbase/management/user_manager.rb', line 156 def drop_group(group_name, = DropGroupOptions.new) @backend.group_drop(group_name, .timeout) end |
#drop_user(username, options = DropUserOptions.new) ⇒ Object
Removes a user
81 82 83 |
# File 'lib/couchbase/management/user_manager.rb', line 81 def drop_user(username, = DropUserOptions.new) @backend.user_drop(.domain, username, .timeout) end |
#get_all_groups(options = GetAllGroupsOptions.new) ⇒ Array<Group>
Gets all groups
122 123 124 125 |
# File 'lib/couchbase/management/user_manager.rb', line 122 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
46 47 48 49 |
# File 'lib/couchbase/management/user_manager.rb', line 46 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
112 113 114 115 |
# File 'lib/couchbase/management/user_manager.rb', line 112 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
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/couchbase/management/user_manager.rb', line 90 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
38 39 40 41 |
# File 'lib/couchbase/management/user_manager.rb', line 38 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
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/couchbase/management/user_manager.rb', line 134 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
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/couchbase/management/user_manager.rb', line 57 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 |