Module: Gitlab::Client::Users
- Included in:
- Gitlab::Client
- Defined in:
- lib/gitlab/client/users.rb
Overview
Defines methods related to users.
Instance Method Summary collapse
-
#add_email(email, user_id = nil) ⇒ Gitlab::ObjectifiedHash
Creates a new email Will create a new email an authorized user if no user ID passed.
-
#block_user(user_id) ⇒ Boolean
Blocks the specified user.
-
#create_ssh_key(title, key) ⇒ Gitlab::ObjectifiedHash
Creates a new SSH key.
-
#create_user(*args) ⇒ Gitlab::ObjectifiedHash
Creates a new user.
-
#delete_email(id, user_id = nil) ⇒ Boolean
Delete email Will delete a email an authorized user if no user ID passed.
-
#delete_ssh_key(id) ⇒ Gitlab::ObjectifiedHash
Deletes an SSH key.
-
#delete_user(user_id) ⇒ Gitlab::ObjectifiedHash
Deletes a user.
-
#edit_user(user_id, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates a user.
-
#email(id) ⇒ Gitlab::ObjectifiedHash
Get a single email.
-
#emails(user_id = nil) ⇒ Gitlab::ObjectifiedHash
Gets user emails.
-
#session(email, password) ⇒ Gitlab::ObjectifiedHash
Creates a new user session.
-
#ssh_key(id) ⇒ Gitlab::ObjectifiedHash
Gets information about SSH key.
-
#ssh_keys(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of user's SSH keys.
-
#unblock_user(user_id) ⇒ Boolean
Unblocks the specified user.
-
#user(id = nil) ⇒ Gitlab::ObjectifiedHash
Gets information about a user.
-
#user_search(search, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Search for groups by name.
-
#users(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of users.
Instance Method Details
#add_email(email, user_id = nil) ⇒ Gitlab::ObjectifiedHash
Creates a new email Will create a new email an authorized user if no user ID passed.
215 216 217 218 |
# File 'lib/gitlab/client/users.rb', line 215 def add_email(email, user_id=nil) url = user_id.to_i.zero? ? "/user/emails" : "/users/#{user_id}/emails" post(url, body: {email: email}) end |
#block_user(user_id) ⇒ Boolean
Blocks the specified user. Available only for admin.
98 99 100 |
# File 'lib/gitlab/client/users.rb', line 98 def block_user(user_id) post("/users/#{user_id}/block") end |
#create_ssh_key(title, key) ⇒ Gitlab::ObjectifiedHash
Creates a new SSH key.
165 166 167 |
# File 'lib/gitlab/client/users.rb', line 165 def create_ssh_key(title, key) post("/user/keys", body: { title: title, key: key }) end |
#create_user(*args) ⇒ Gitlab::ObjectifiedHash
Creates a new user. Requires authentication from an admin account.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gitlab/client/users.rb', line 50 def create_user(*args) = Hash === args.last ? args.pop : {} body = if args[2] { email: args[0], password: args[1], username: args[2] } else { email: args[0], password: args[1], name: args[0] } end body.merge!() post('/users', body: body) end |
#delete_email(id, user_id = nil) ⇒ Boolean
Delete email Will delete a email an authorized user if no user ID passed.
230 231 232 233 |
# File 'lib/gitlab/client/users.rb', line 230 def delete_email(id, user_id=nil) url = user_id.to_i.zero? ? "/user/emails/#{id}" : "/users/#{user_id}/emails/#{id}" delete(url) end |
#delete_ssh_key(id) ⇒ Gitlab::ObjectifiedHash
Deletes an SSH key.
176 177 178 |
# File 'lib/gitlab/client/users.rb', line 176 def delete_ssh_key(id) delete("/user/keys/#{id}") end |
#delete_user(user_id) ⇒ Gitlab::ObjectifiedHash
Deletes a user.
87 88 89 |
# File 'lib/gitlab/client/users.rb', line 87 def delete_user(user_id) delete("/users/#{user_id}") end |
#edit_user(user_id, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates a user.
76 77 78 |
# File 'lib/gitlab/client/users.rb', line 76 def edit_user(user_id, ={}) put("/users/#{user_id}", body: ) end |
#email(id) ⇒ Gitlab::ObjectifiedHash
Get a single email.
201 202 203 |
# File 'lib/gitlab/client/users.rb', line 201 def email(id) get("/user/emails/#{id}") end |
#emails(user_id = nil) ⇒ Gitlab::ObjectifiedHash
Gets user emails. Will return emails an authorized user if no user ID passed.
189 190 191 192 |
# File 'lib/gitlab/client/users.rb', line 189 def emails(user_id=nil) url = user_id.to_i.zero? ? "/user/emails" : "/users/#{user_id}/emails" get(url) end |
#session(email, password) ⇒ Gitlab::ObjectifiedHash
This method doesn't require private_token to be set.
Creates a new user session.
122 123 124 |
# File 'lib/gitlab/client/users.rb', line 122 def session(email, password) post("/session", body: { email: email, password: password }, unauthenticated: true) end |
#ssh_key(id) ⇒ Gitlab::ObjectifiedHash
Gets information about SSH key.
153 154 155 |
# File 'lib/gitlab/client/users.rb', line 153 def ssh_key(id) get("/user/keys/#{id}") end |
#ssh_keys(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of user's SSH keys.
137 138 139 140 141 142 143 144 |
# File 'lib/gitlab/client/users.rb', line 137 def ssh_keys(={}) user_id = .delete :user_id if user_id.to_i.zero? get("/user/keys", query: ) else get("/users/#{user_id}/keys", query: ) end end |
#unblock_user(user_id) ⇒ Boolean
Unblocks the specified user. Available only for admin.
109 110 111 |
# File 'lib/gitlab/client/users.rb', line 109 def unblock_user(user_id) post("/users/#{user_id}/unblock") end |
#user(id = nil) ⇒ Gitlab::ObjectifiedHash
Gets information about a user. Will return information about an authorized user if no ID passed.
28 29 30 |
# File 'lib/gitlab/client/users.rb', line 28 def user(id=nil) id.to_i.zero? ? get("/user") : get("/users/#{id}") end |
#user_search(search, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Search for groups by name
245 246 247 248 |
# File 'lib/gitlab/client/users.rb', line 245 def user_search(search, ={}) [:search] = search get("/users", query: ) end |
#users(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of users.
15 16 17 |
# File 'lib/gitlab/client/users.rb', line 15 def users(={}) get("/users", query: ) end |